-
Notifications
You must be signed in to change notification settings - Fork 0
/
Facebook_add_friend.py
106 lines (86 loc) · 4.19 KB
/
Facebook_add_friend.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
import pandas as pd
from colorama import Fore, Back, Style
import random
import pyfiglet
randomnumber = round(random.uniform(0, 1000))
randomsleeptime = round(random.uniform(10, 25))
ascii_banner = pyfiglet.figlet_format(
"A D D F R I E N D")
df = pd.read_csv('./accounts and comment/ያገርቤትስም.csv')
print(ascii_banner)
print(Back.GREEN, Fore.YELLOW)
randomname = df.iloc[randomnumber]
print(randomname)
print(Style.RESET_ALL)
df = pd.read_excel("./accounts and comment/accounts_for_add_friend.xlsx")
usernames = df['ስም'].tolist()
passwords = df['ቁልፍ'].tolist()
for i in range(0, len(usernames)):
chrome_options = webdriver.ChromeOptions()
prefs = {
"profile.default_content_setting_values.geolocation": 2}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--incognito")
driver = webdriver.Chrome(service=Service(
ChromeDriverManager().install()), options=chrome_options)
driver.get("https://www.facebook.com")
x = driver.find_element(
By.XPATH, "//input[@id='email']").send_keys(usernames[i])
time.sleep(1)
x = driver.find_element(
By.XPATH, "//input[@id='pass']").send_keys(passwords[i])
time.sleep(10)
d = driver.find_element(By.NAME, "login")
d.click()
time.sleep(randomsleeptime)
elem = driver.find_element(
By.XPATH, "/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[2]/div[1]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/label[1]/input[1]")
elem.click()
elem.send_keys(randomname)
time.sleep(randomsleeptime)
elem.send_keys(Keys.RETURN)
seemore = driver.find_element(
By.XPATH, "/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[5]/div[1]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/a[1]/div[1]/div[1]/div[1]/span[1]/span[1]")
seemore.click()
time.sleep(randomsleeptime)
addfriends = driver.find_elements(
By.CLASS_NAME, "x1i10hfl.xjbqb8w.x6umtig.x1b1mbwd.xaqea5y.xav7gou.x1ypdohk.xe8uvvx.xdj266r.x11i5rnm.xat24cr.x1mh8g0r.xexx8yu.x4uap5.x18d9i69.xkhd6sd.x16tdsg8.x1hl2dhg.xggy1nq.x1o1ewxj.x3x9cwd.x1e5q0jg.x13rtm0m.x87ps6o.x1lku1pv.x1a2a7pz.x9f619.x3nfvp2.xdt5ytf.xl56j7k.x1n2onr6.xh8yej3")
time.sleep(randomsleeptime)
print(Back.GREEN)
print(addfriends)
print(len(addfriends), "-friends to add")
count = 0
for friend in addfriends:
if friend.get_attribute('aria-label') == "Add friend":
friend.click()
count += 1
if count >= 5:
break
time.sleep(randomsleeptime)
else:
break
print("nnnnnnnnnnnnnooooooooooooooooooooo")
print(Style.RESET_ALL)
time.sleep(randomsleeptime)
account = driver.find_element(By.CLASS_NAME, "x1i10hfl.x1qjc9v5.xjbqb8w.xjqpnuy.xa49m3k.xqeqjp1.x2hbi6w.x13fuv20.xu3j5b3.x1q0q8m5.x26u7qi.x972fbf.xcfux6l.x1qhh985.xm0m39n.x9f619.x1ypdohk.xdl72j9.x2lah0s.xe8uvvx.xdj266r.x11i5rnm.xat24cr.x1mh8g0r.x2lwn1j.xeuugli.xexx8yu.x4uap5.x18d9i69.xkhd6sd.x1n2onr6.x16tdsg8.x1hl2dhg.xggy1nq.x1ja2u2z.x1t137rt.x1o1ewxj.x3x9cwd.x1e5q0jg.x13rtm0m.x1q0g3np.x87ps6o.x1lku1pv.x1a2a7pz.xzsf02u.x1rg5ohu")
account.click()
time.sleep(randomsleeptime)
logout = driver.find_element(
By.XPATH, "/html[1]/body[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[3]/div[2]/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[5]/div[1]")
print(account)
logout.click()
time.sleep(randomsleeptime)
driver.close()
# def login():