-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (30 loc) · 1.15 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
#disables the popups in chrome
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)
#opens facebook
driver.get("https://www.facebook.com")
#types your email
email = driver.find_element_by_xpath('//*[@id="email"]')
email.send_keys('Your email address')
#types your password
password = driver.find_element_by_xpath('//*[@id="pass"]')
password.send_keys('Your password')
#clicks login button
button =driver.find_element_by_xpath('//*[@id="loginbutton"]')
button.click()
#reads content of file 'quotes_file.txt'
with open('quotes_file.txt') as myfile:
data = myfile.read()
#types content of file into post box of facebook
post_box=driver.find_element_by_xpath("//*[@name='xhpc_message']")
post_box.click()
post_box.send_keys(data)
time.sleep(5)
#clicks the post button
post_it=driver.find_element_by_xpath("//*[@id='u_0_1a']/div/div[6]/div/ul/li[2]/button")
post_it.click()