Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【Python】標準入力でヤフー検索をして検索結果をスクリーンショットを撮影する方法
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
You can’t perform that action at this time.