Last active
February 14, 2016 05:44
-
-
Save kurozumi/dcffd0bfac0aca39eec6 to your computer and use it in GitHub Desktop.
【Python】Seleniumを使ってツイッターに自動で投稿(ツイート)する方法
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 | |
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) | |
tweet = driver.find_element_by_name("tweet") | |
tweet.click() | |
tweet.send_keys("from selenium") | |
button = driver.find_element_by_class_name("tweet-action") | |
button.click() | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment