Created
September 13, 2017 05:51
-
-
Save madogiwa0124/6a82814efe7afd2cdabb69c89e59d169 to your computer and use it in GitHub Desktop.
Moookのページ投稿自動化ツール
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ========================== | |
| # Moookページ登録 自動化ツール | |
| # ========================== | |
| # ========================== | |
| # 外部ライブラリの読み込み | |
| # ========================== | |
| require 'mechanize' | |
| # ========================== | |
| # 定数管理 | |
| # ========================== | |
| USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.63 Safari/537.36' | |
| MAIL_ADDRESS = "hogehoge" | |
| PASSWORD = "hogehoge" | |
| # ========================== | |
| # 本体 | |
| # ========================== | |
| # 初期設定 | |
| agent = Mechanize.new | |
| agent.user_agent = USER_AGENT | |
| agent.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
| # ページへアクセス | |
| url = 'https://moook.herokuapp.com/' | |
| page = agent.get(url) | |
| # ログイン | |
| next_page = page.form_with(action: "/users/sign_in") do |form| | |
| form.field_with(name: "user[email]").value = MAIL_ADDRESS | |
| form.field_with(name: "user[password]").value = PASSWORD | |
| end.submit | |
| p next_page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment