Advertisement
Guest User

Facebook bot NO API !

a guest
Mar 9th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.63 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import WebDriverWait
  4. from selenium.webdriver.support import expected_conditions as EC
  5. from selenium.webdriver.common.keys import Keys
  6. from selenium.webdriver.support.ui import Select
  7. from selenium.webdriver.common.action_chains import ActionChains
  8. import random
  9. import time
  10.  
  11. loginnow = False;
  12. chrome_options = webdriver.ChromeOptions()
  13. chrome_options.add_argument("--mute-audio")
  14. driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe", chrome_options=chrome_options);
  15. driver.get("https://www.facebook.com/");
  16.  
  17. user = raw_input("Write your E-mail to login :");
  18. if(user):
  19.     password = raw_input("Write your password to login :");
  20.     if(password):
  21.         loginnow = True;
  22.     elif(password != null):
  23.         driver.quit()
  24. elif(user != null):
  25.     driver.quit()
  26.  
  27. def login():
  28.     emailid = driver.find_element_by_id('email');
  29.     emailid.send_keys(user);
  30.     time.sleep(2)
  31.     passid = driver.find_element_by_id('pass');
  32.     passid.send_keys(password);
  33.     time.sleep(2);
  34.     loginbutton = driver.find_element_by_id("loginbutton");
  35.     driver.execute_script("arguments[0].scrollIntoView();", loginbutton)
  36.     time.sleep(2)
  37.     driver.execute_script("arguments[0].click();", loginbutton)
  38.     print "Logged in"
  39.    
  40. def friendaccept():
  41.     friendrequestpage = driver.find_element_by_class_name("jewelButton")
  42.     driver.execute_script("arguments[0].scrollIntoView();", friendrequestpage)
  43.     driver.execute_script("arguments[0].click();", friendrequestpage)
  44.     time.sleep(2)
  45.     seemorefriend = driver.find_element_by_class_name("seeMore")
  46.     driver.execute_script("arguments[0].scrollIntoView();", seemorefriend)
  47.     driver.execute_script("arguments[0].click();", seemorefriend)
  48.     time.sleep(2)
  49.     friendquestcount = 1
  50.     friendquantity = raw_input("How many friend requests do you wish to accept?");
  51.     while(int(friendquantity) != friendquestcount):
  52.         acceptfriend = driver.find_element_by_xpath("//button[" + str(friendquestcount) + "][text()='Bevestigen']") #change this "Bevestigen" word to the english word Accept or accept
  53.         driver.execute_script("arguments[0].click();", acceptfriend)
  54.         friendquestcount += 1
  55.         if(friendquantity == friendquestcount):
  56.             print "Done"
  57.  
  58.  
  59. def groupjoin():
  60.     groupniche = raw_input("What is your niche? :")
  61.     if(groupniche):
  62.         time.sleep(2)
  63.         groupsearch = driver.find_element_by_class_name("inputtext");
  64.         driver.execute_script("arguments[0].scrollIntoView();", groupsearch)
  65.         time.sleep(2)
  66.         groupsearch.send_keys(groupniche)
  67.         time.sleep(2)
  68.         seemoregroup = driver.find_element_by_class_name("seeMoreV2")
  69.         driver.execute_script("arguments[0].scrollIntoView();", seemoregroup)
  70.         driver.execute_script("arguments[0].click();", seemoregroup)
  71.         time.sleep(2)
  72.         finderhier = 0;
  73.         try:
  74.             seemorev1group = driver.find_element_by_xpath("//a[text()='Meer weergeven']") #change this to See more
  75.             driver.execute_script("arguments[0].scrollIntoView();", seemorev1group)
  76.             driver.execute_script("arguments[0].click();", seemorev1group)
  77.             time.sleep(2)
  78.             howmanygroups = raw_input("how many groups do you wish to join ? MAX 20 else you'll get blocked on FB");
  79.             groephoeveel = 0
  80.             while(groephoeveel != howmanygroups):
  81.                 try:
  82.                     time.sleep(2)
  83.                     joingroupnow = driver.find_element_by_xpath("//a[text()='Lid worden']") #change this to Join group in english
  84.                     time.sleep(2)
  85.                     driver.execute_script("window.scroll(0,400)")
  86.                     driver.execute_script("arguments[0].scrollIntoView();", joingroupnow)
  87.                     joingroupnow.click()
  88.                     groephoeveel += 1
  89.                     if(groephoeveel == howmanygroups):
  90.                         print "done"
  91.                         break
  92.                 except:
  93.                     print "No groups has been found ! try to choose a different niche!"
  94.                     driver.execute_script("window.scroll(0,50)")
  95.                     pass
  96.         except:
  97.             driver.switch_to_default_content()
  98.             time.sleep(2)
  99.             driver.execute_script("window.scroll(0,400)")
  100.             time.sleep(3)
  101.             seemorev1group = driver.find_element_by_xpath("//a[text()='Meer weergeven']") #change this to See more
  102.             driver.execute_script("arguments[0].scrollIntoView();", seemorev1group)
  103.             driver.execute_script("arguments[0].click();", seemorev1group)
  104.             time.sleep(3)
  105.             groeps = driver.find_element_by_xpath("//div[text()='Groepen'") #change this to groups
  106.             driver.execute_script("arguments[0].scrollIntoView();", groeps)
  107.             driver.execute_script("arguments[0].click();", groeps)
  108.             time.sleep(2)
  109.             driver.execute_script("window.scroll(0,50")
  110.             pass;
  111.            
  112.             if(groephoeveel == howmanygroups):
  113.                 print "Done"
  114.        
  115.     else:
  116.         print "not working"
  117.    
  118. def commands():
  119.     commandq = raw_input("For group function type !grp for accepting friendrequests type !frq")
  120.     if(commandq == "!frq" or commandq == "!FRQ"):
  121.         friendaccept()
  122.     elif(commandq == "!grp" or commandq == "!GRP"):
  123.         groupjoin()
  124.        
  125.  
  126.  
  127.  
  128. if(loginnow):
  129.     login()
  130.     questionnow = raw_input("Write !c for commands.");
  131.     if(questionnow == "!c" or questionnow == "!C"):
  132.         commands()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement