from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time class FacebookBot: def __init__(self, email, password): chrome_options = Options() chrome_options.add_argument("--disable-notifications") service = Service('C:/chromedriver/chromedriver.exe') self.driver = webdriver.Chrome(service=service, options=chrome_options) self.driver.get("https://www.facebook.com") self.login(email, password) def login(self, email, password): email_input = self.driver.find_element(By.ID, "email") password_input = self.driver.find_element(By.ID, "pass") email_input.send_keys(email) password_input.send_keys(password) password_input.send_keys(Keys.RETURN) time.sleep(5) # Giriş işlemi için bekle def send_friend_requests(self, group_urls, limit=15): total_requests = 0 for group_url in group_urls: self.driver.get(group_url + "/members") time.sleep(5) # Sayfanın yüklenmesini bekle new_members_section = self.driver.find_element(By.XPATH, "//span[contains(text(), 'Grupta Yeni')]") self.driver.execute_script("arguments[0].scrollIntoView();", new_members_section) time.sleep(2) add_friend_buttons = self.driver.find_elements(By.XPATH, "//span[contains(text(), 'Grupta Yeni')]/following-sibling::div//button[contains(text(), 'Arkadaş ekle')]") for button in add_friend_buttons[:limit]: self.driver.execute_script("arguments[0].scrollIntoView();", button) WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable(button)).click() print("Sent friend request") time.sleep(2) total_requests += 1 if total_requests % 15 == 0: print("15 friend requests sent, taking a break...") time.sleep(15 * 60) # 15 dakika bekle print("All friend requests sent, taking a final break...") time.sleep(15 * 60) # Tüm işlemler bittikten sonra 15 dakika bekle def invite_to_group(self, group_url): self.driver.get(group_url) time.sleep(5) # Sayfanın yüklenmesini bekle invite_button = self.driver.find_element(By.XPATH, "//button[contains(text(), 'Invite')]") invite_button.click() time.sleep(2) invite_friends_button = self.driver.find_element(By.XPATH, "//button[contains(text(), 'Invite Friends')]") invite_friends_button.click() time.sleep(2) friends = self.driver.find_elements(By.XPATH, "//div[@role='checkbox']") for friend in friends[:15]: friend.click() send_invites_button = self.driver.find_element(By.XPATH, "//button[contains(text(), 'Send Invites')]") send_invites_button.click() print("Invited 15 friends to the group") # Kullanıcı bilgilerini girin email = "anda.sakin" password = "Mediha18" # Botu başlat bot = FacebookBot(email, password) # Grup URL'lerini girin group_urls = [ "https://www.facebook.com/groups/1537376026440013", "https://www.facebook.com/groups/354931426462028", "https://www.facebook.com/groups/284636805859453", "https://www.facebook.com/groups/amazon90deal", "https://www.facebook.com/groups/amazonclearancesale" ] # Arkadaşlık isteklerini gönder bot.send_friend_requests(group_urls) # Kendi grubunuza davet edin your_group_url = "https://www.facebook.com/groups/occasiondeals" bot.invite_to_group(your_group_url)