Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active February 14, 2016 05:43
Show Gist options
  • Save kurozumi/4ed136f2e4237863e435 to your computer and use it in GitHub Desktop.
Save kurozumi/4ed136f2e4237863e435 to your computer and use it in GitHub Desktop.
【Python】Seleniumを使ってツイッター検索する方法
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.implicitly_wait(10)
driver.get('https://twitter.com')
login = driver.find_element_by_css_selector(".StreamsLogin")
login.click()
username = driver.find_element_by_xpath("//input[contains(@name, 'username_or_email')]")
username.send_keys("username")
password = driver.find_element_by_xpath("//input[contains(@name, 'password')]")
password.send_keys("password")
password.send_keys(Keys.RETURN)
search = driver.find_element_by_name("q")
search.send_keys("twitter")
search.send_keys(Keys.RETURN)
driver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment