├── fb.png ├── README.md ├── facebookbot.py └── twitterbot.py /fb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Anil-matcha/twitterbot/master/fb.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Script to open a browser , login to twitter.com and post a tweet automatically 2 | 3 | Module used 4 | Selenium 5 | -------------------------------------------------------------------------------- /facebookbot.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.keys import Keys 3 | from time import sleep 4 | from selenium.common.exceptions import TimeoutException 5 | from selenium.webdriver.support.ui import WebDriverWait 6 | from selenium.webdriver.support.ui import Select 7 | from selenium.webdriver.common.by import By 8 | from selenium.webdriver.support import expected_conditions 9 | from selenium.common.exceptions import NoSuchElementException 10 | import time 11 | 12 | driver = webdriver.Firefox() 13 | driver.get('https://www.facebook.com/') 14 | print("Opened facebook...") 15 | time.sleep(2) 16 | email = driver.find_element_by_xpath("//input[@id='email' or @name='email']") 17 | email.send_keys('achinsagar@gmail.com') 18 | print("Email Id entered...") 19 | password = driver.find_element_by_xpath("//input[@id='pass']") 20 | password.send_keys('19indep47') 21 | print("Password entered...") 22 | button = driver.find_element_by_xpath("//input[@id='u_0_w']") 23 | button.click() 24 | time.sleep(2) 25 | statusbox = driver.find_element_by_xpath("//textarea[@class='uiTextareaAutogrow _3en1']") 26 | statusbox.send_keys("Bot is typing here"); 27 | postbutton = driver.find_element_by_xpath("//*[text()='Post']") 28 | postbutton.click() -------------------------------------------------------------------------------- /twitterbot.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.keys import Keys 3 | from time import sleep 4 | from selenium.common.exceptions import TimeoutException 5 | from selenium.webdriver.support.ui import WebDriverWait 6 | from selenium.webdriver.support.ui import Select 7 | from selenium.webdriver.common.by import By 8 | from selenium.webdriver.support import expected_conditions 9 | from selenium.common.exceptions import NoSuchElementException 10 | 11 | driver = webdriver.Firefox() 12 | driver.get('https://www.twitter.com/') 13 | print("Opened twitter...") 14 | login = driver.find_element_by_xpath("//*[@class='Button StreamsLogin js-login']") 15 | login.click() 16 | email = driver.find_element_by_xpath("//*[@class='text-input email-input js-signin-email']") 17 | email.send_keys('Enter your email address here') 18 | print("Email Id entered...") 19 | password = driver.find_element_by_xpath("//*[@name='session[password]']") 20 | password.send_keys('Enter your password is here') 21 | print("Password entered...") 22 | button = driver.find_element_by_xpath("//*[@class='submit btn primary-btn js-submit']") 23 | button.click() 24 | driver.find_element_by_xpath("//div[@id='tweet-box-home-timeline']").send_keys("Bot is tweeting here"); 25 | tweetbutton = driver.find_element_by_xpath("//*[@class='btn primary-btn tweet-action tweet-btn js-tweet-btn']") 26 | tweetbutton.click() --------------------------------------------------------------------------------