ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
Ruby+Mechanize+Cgi で、Twitter のログイン
日時: 2014/07/17 17:49
名前: lightbox



ruby_test1.rb
拡張子:
print "Content-Type: text/html; charset=utf-8\n\n"

require "cgi"
cgi = CGI.new(:accept_charset => 'utf-8')

require 'mechanize'
agent = Mechanize.new

agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
agent.follow_meta_refresh = true
agent.user_agent = 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'

page = agent.get("https://twitter.com/")

form = page.forms[1]
form["session[username_or_email]"] = cgi['user']
form["session[password]"] = cgi['pass']
page = form.submit

page = agent.get("https://twitter.com/")

print page.body
拡張子:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<form action="ruby_test1.rb" method="post">
<input type="text" name="user">
<input type="password" name="pass">
<input type="submit" name="send">
</form>
メンテナンス


日時: 2014/07/17 17:49
名前: lightbox