Last active
October 8, 2015 01:14
-
-
Save stmtk1/130840c59652ee39b649 to your computer and use it in GitHub Desktop.
This file contains 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
require "watir-webdriver" | |
require "nokogiri" | |
ff = Watir::Browser.new :ff # variable ff is firefox | |
ff.goto "https://twitter.com" | |
# login with your account | |
ff.button(:type => "submit").click | |
ff.text_field(:id => "signin-email").set "" # スクリーンネーム | |
ff.text_field(:id => "signin-password").set "" # パスワード | |
ff.button(:class => "submit btn primary-btn js-submit" ).click | |
ff.goto "https://twitter.com/stmtk_01/followers" | |
# ログインできなかった場合 | |
if ff.url == "https://twitter.com/login?redirect_after_login=%2Ffollowers%2F" | |
form = ff.divs(:id => "page-container")[0] | |
form.text_field(:name => "session[username_or_email]").set "stmtk_01" | |
form.text_field(:name => "session[password]").set "hzrglnlglpr" | |
form.button(:class => "submit btn primary-btn").click | |
end | |
# ログインし終わり | |
gets | |
doc = Nokogiri::HTML.parse(ff.html) | |
doc.xpath('/html/body//div[@id="page-outer"]//div[@class="AppContainer"]//div[@class="Grid Grid--withGutter"]/ /div[@class="Grid Grid--withGutter"]//div[@class="GridTimeline"]/div[@class="GridTimeline-items"]/div[@class=" Grid Grid--withGutter"]').each do |page| | |
docs = Nokogiri::HTML.parse(page.to_s) | |
p docs.xpath('/div') | |
end | |
ff.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment