Last active
February 18, 2016 00:29
-
-
Save kurozumi/518f97b081deed224006 to your computer and use it in GitHub Desktop.
【Python】標準入力でヤフー検索をして検索結果をスクリーンショットを撮影する方法
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
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from datetime import datetime | |
# 標準入力の値を取得 | |
keyword = raw_input() | |
driver = webdriver.Firefox() | |
driver.implicitly_wait(10) | |
# ヤフーにアクセス | |
driver.get("http://www.yahoo.co.jp/") | |
elem = driver.find_element_by_name("p") | |
# キーワード入力 | |
elem.send_keys(keyword) | |
# 検索 | |
elem.send_keys(Keys.RETURN) | |
# スクリーンショットを撮影 | |
driver.save_screenshot("%s.png" % datetime.now()) | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment