12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- from setup import *
- programname = 'LIKEPOSTS'
- userdatadir, userlist, config, minimize, approval = setup(programname)
- def execute():
- try:
- maxlikes = int(config[programname]['maxlikecount'])
- print("Liking up to "+ str(maxlikes) + " posts")
- tsleep(5)
- except:
- print("Invalid settings. Please check settings and try again.")
- tsleep(5)
- return 0
- driver, selecteduser=restart_browser(userdatadir, userlist)
- if minimize == 1:
- driver.minimize_window()
- print(selecteduser)
- try:
- driver.get('https://www.facebook.com/friends/requests')
- except:
- traceback.print_exc()
- print("Can't get URL or invalid URL. Please check the URL and try again.")
- tsleep(5)
- driver.quit()
- return 0
- # CHECK IF YOU ARE LOGGED IN
- if "login" in driver.current_url:
- print("Not logged in. Please make sure you are logged in.")
- tsleep(5)
- driver.quit()
- return 0
- # YOU HAVE LOGGED IN AT THIS POINT -- MAIN PROGRAM EXECUTION STARTS HERE
- try:
- driver.get('https://www.facebook.com')
- except:
- print("Can't get URL or invalid URL. Please check the URL and try again.")
- tsleep(5)
- return 0
-
- maxscroll = math.ceil(maxlikes / 7) + 2
- for i in range(1,maxscroll):
- driver.execute_script("window.scrollBy(0,document.body.scrollHeight)")
- tsleep(2)
- req = driver.find_elements(By.XPATH, "//*[contains(@class,'bdao358l om3e55n1 g4tp4svg alzwoclg cqf1kptm gvxzyvdx aeinzg81 jg3vgc78 cgu29s5g i15ihif8 pdnn8mpk f1iqohp5 bmgto6uh f9xcifuu')]") #like btn
- reqs=[]
- for i in req:
- if i.text == "Like" or i.text == "讚":
- reqs.append(i)
- author = driver.find_elements(By.XPATH, "//*[contains(@class,'alzwoclg om3e55n1 mfclru0v')]")
- authors = []
- for a in author:
- if a.text != "":
- authors.append(a)
- tags = driver.find_elements(By.XPATH, "//*[contains(@class,'qi72231t nu7423ey n3hqoq4p r86q59rh b3qcqh3k fq87ekyn bdao358l fsf7x5fv rse6dlih s5oniofx m8h3af8h l7ghb35v kjdc1dyq kmwttqpk srn514ro oxkhqvkx rl78xhln nch0832m cr00lzj9 rn8ck1ys s3jn8y49 icdlwmnq jxuftiz4 cxfqmxzd tes86rjd')]")
- posts = driver.find_elements(By.XPATH, "//*[contains(@class,'qi72231t nu7423ey n3hqoq4p r86q59rh b3qcqh3k fq87ekyn bdao358l fsf7x5fv rse6dlih s5oniofx m8h3af8h l7ghb35v kjdc1dyq kmwttqpk srn514ro oxkhqvkx rl78xhln nch0832m cr00lzj9 rn8ck1ys s3jn8y49 icdlwmnq jxuftiz4 cxfqmxzd tes86rjd')]")
- print(len(reqs))
- print(len(authors))
- print(len(tags))
- print(output(reqs))
- print(output(authors))
- count = 0 #maximum posts liked at a time specified in ini
-
- #for req, author in zip(reqs, authors):
- for req in reqs:
- count += 1
- print("Post found")
- print(req.text)
-
- tsleep(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()
- #db['friend_requests'].insert({"datetime":datetime.now(), "name": lines[0], "page_link": url, "request_age": lines[1], "server_ID": serverid, "profile": selecteduser})
-
- print("Completed")
- if count == maxlikes:
- break
- if approval == 1:
- execute()
|