123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- import time
- import configparser
- import sys
- def restart_browser(userdatadir):
- options = webdriver.ChromeOptions()
- options.add_argument("start-maximized")
- # options.add_argument('user-data-dir=C:/Users/XXXXXXXXX/AppData/Local/Google/Chrome/User Data/') # replace XXXXXXXXX with your own username
- options.add_argument('user-data-dir='+userdatadir) # replace XXXXXXXXX with your own username
- options.add_argument('--profile-directory="Default"')
- driver=webdriver.Chrome(chrome_options=options)
- driver.set_window_size(1400,1000)
- return driver
- config = configparser.ConfigParser()
- #config.sections()
- config.read('c:/portable/choozmo.ini')
- userdatadir=config['DEFAULT']['userdatadir']
- #for k,v in config['DEFAULT'].items():
- # print(k)
- #sys.exit()
- driver=restart_browser(userdatadir)
- driver.get('https://www.facebook.com/friends/requests')
- #friend request confirm
- reqs = driver.find_elements(By.XPATH, "//*[contains(@class,'l9j0dhe7 du4w35lb j83agx80 pfnyh3mw taijpn5t bp9cbjyn owycx6da btwxx1t3 kt9q3ron ak7q8e6j isp2s0ed ri5dt5u2 rt8b4zig n8ej3o3l agehan2d sk4xxmp2 rq0escxv d1544ag0 tw6a2znq s1i5eluu tv7at329')]")
- #friend request reject -- just in case if needed
- #reqs = driver.find_elements(By.XPATH, "//*[contains(@class,'l9j0dhe7 du4w35lb j83agx80 pfnyh3mw taijpn5t bp9cbjyn owycx6da btwxx1t3 kt9q3ron ak7q8e6j isp2s0ed ri5dt5u2 rt8b4zig n8ej3o3l agehan2d sk4xxmp2 rq0escxv d1544ag0 tw6a2znq tdjehn4e tv7at329')]")
- print(reqs)
- for req in reqs:
- print("Friend request!")
- time.sleep(15) #just in case you want to change your mind...
- webdriver.ActionChains(driver).move_to_element(req).perform()
- webdriver.ActionChains(driver).move_to_element(req).click().perform()
- time.sleep(15)
- print("Completed")
- time.sleep(500)
- driver.quit()
|