Last active
March 11, 2016 02:54
-
-
Save kumagi/0457c38dd9fa0e8437fe 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 'selenium-webdriver' | |
class KensakuOuen | |
def initialize() | |
@driver = Selenium::WebDriver.for :firefox | |
end | |
def search(keyword) | |
begin | |
@driver.manage.delete_all_cookies | |
@driver.get "http://www.yahoo.co.jp" | |
input = @driver.find_elements(:id => "srchtxt", :tag_name => "input")[0] | |
input.send_keys(keyword) | |
btn = @driver.find_elements(:id => "srchbtn", :tag_name => "input")[0] | |
btn.click | |
ret = @driver.page_source | |
rescue => e | |
p e | |
ensure | |
sleep 1 | |
end | |
ret | |
end | |
end | |
k = KensakuOuen.new | |
loop do | |
k.search("3.11") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment