Created
June 17, 2016 09:10
-
-
Save ir-norn/a006516fda27c1c36458a7feec17f72e 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' | |
agent = Selenium::WebDriver.for :firefox | |
agent.get "http://motenai.orz.hm/up/" | |
agent.find_element(:name => "file[]").send_keys "C:\\0.jpg" | |
agent.find_element(:name => "pass").send_keys "1234" | |
f = agent.find_element :name => "file[]" | |
f.submit | |
sleep 1 | |
p 2 | |
#agent.find_element(:name, 'element_with_alert_javascript').click rescue $! | |
#sleep 1 | |
p 1 | |
a = agent.switch_to.alert | |
if a.text == 'A value you are looking for' | |
p 3 | |
a.dismiss | |
else | |
p 4 | |
a.accept | |
end |
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' | |
driver = Selenium::WebDriver.for :firefox | |
driver.get "http://s1.gazo.cc/" | |
element = driver.find_element :name => "upfile" | |
element.send_keys "C:\\0.jpg" | |
element.submit | |
driver.quit |
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' | |
agent = Selenium::WebDriver.for :firefox | |
agent.get "http://www.tinami.com/login" | |
agent.find_element(:name => "username").send_keys "mail" | |
f = agent.find_element(:name => "password").send_keys "pass" | |
f.submit | |
sleep 1 | |
agent.get "http://www.tinami.com/upload" | |
agent.find_element(:name => "file").send_keys "C:\\0.jpg" | |
agent.find_element(:name => "title").send_keys "taitoru" | |
agent.find_element(:name => "description").send_keys "せつめいー。" | |
# ラジオボタン選択 | |
agent.find_elements(:name, 'form-cont_type')[0].click | |
agent.find_elements(:name, 'form-cont_style')[1].click | |
agent.find_elements(:name, 'form-character_type')[2].click | |
f = agent.find_element(:name => "genrekey").send_keys "テスト" | |
f.submit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment