-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacebook_automation.py
74 lines (59 loc) · 3.52 KB
/
facebook_automation.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 30 19:03:04 2021
@author: anime
"""
# This Program will go on facebook and log with provided id pss and open the user Profile
# Importing required libraries
import time
from selenium import webdriver
# Lets Begin
# Dealing with Notifications pop in facebook
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)
# Get start with Google
driver.get('https://www.google.com/')
time.sleep(5)
# Typing Facebook
driver.find_element_by_name('q').send_keys('Facebook')
time.sleep(3)
driver.find_element_by_class_name('gNO89b').click()
time.sleep(5)
# Open login page of Facebook
driver.find_element_by_class_name('l').click()
time.sleep(5)
# Typing Email Id Password (write email id and password in place of --)
driver.find_element_by_name('email').send_keys('[email protected]')
time.sleep(2)
driver.find_element_by_name('pass').send_keys('------------')
time.sleep(2)
driver.find_element_by_name('login').click()
time.sleep(7)
# Posting Status
#button1 = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[1]/div/div[1]/span').click()
#time.sleep(5)
#driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/form/div/div[1]/div/div/div[2]/div[1]/div[1]/div[1]/div/div/div/div/div[2]/div').send_keys('Hello Guys..')
#time.sleep(8)
#post = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/form/div/div[1]/div/div/div[3]/div[2]/div').click()
#time.sleep(5)
# Liking Post
like1 = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div[2]/div/div/div[3]/div/div[4]/div/div[1]/div/div/div/div/div/div/div/div/div/div/div[2]/div/div[4]/div/div/div[1]/div/div[2]/div/div[1]/div[1]').click()
time.sleep(5)
like2 = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div[2]/div/div/div[3]/div/div[4]/div/div[3]/div/div/div/div/div/div/div/div/div/div/div[2]/div/div[4]/div/div/div[1]/div/div[2]/div/div[1]/div[1]').click()
time.sleep(5)
like3 = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div[2]/div/div/div[3]/div/div[4]/div/div[5]/div/div/div/div/div/div/div/div/div/div/div[2]/div/div[4]/div/div/div[1]/div/div[2]/div/div[1]/div[1]').click()
time.sleep(5)
like4 = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div/div[2]/div/div/div[3]/div/div[4]/div/div[7]/div/div/div/div/div/div/div/div/div/div/div[2]/div/div[4]/div/div/div[1]/div/div[2]/div/div[1]/div[1]').click()
time.sleep(5)
# Opening Profile
video = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[2]/div[3]/div/div[1]/div[1]/ul/li[2]/span/div/a').click()
time.sleep(5)
group = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[2]/div[3]/div/div[1]/div[1]/ul/li[4]/span/div/a').click()
time.sleep(5)
gaming = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[2]/div[3]/div/div[1]/div[1]/ul/li[5]/span/div/a').click()
time.sleep(5)
profile = driver.find_element_by_xpath('//*[@id="mount_0_0"]/div/div[1]/div/div[2]/div[4]/div[1]/div[4]/a').click()
time.sleep(20)
driver.quit()