Facebook
From Ungracious Cat, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 122
  1. from selenium import webdriver
  2. from selenium.webdriver.common.action_chains import ActionChains
  3. from webdriver_manager.chrome import ChromeDriverManager
  4. import time
  5.  
  6. class WykopBot():
  7.     def __init__(self):
  8.         self.driver = webdriver.Chrome(ChromeDriverManager().install())
  9.    
  10.     def login(self):
  11.         self.driver.get('https://wykop.pl')
  12.    
  13.    
  14. login = input('Podaj login: ')
  15. haslo = input('Podaj haslo: ')
  16.  
  17. bot = WykopBot()
  18. bot.login()
  19. bot.driver.maximize_window()
  20.  
  21. wykop_login_btn = bot.driver.find_element_by_xpath('//*[@id="nav"]/div/ul[2]/li[4]/a')
  22. wykop_login_btn.click()
  23.  
  24. wykop_login_input = bot.driver.find_element_by_xpath('//*[@id="newregister-login"]')
  25. wykop_login_input.click()
  26. wykop_login_input.send_keys(f'{login}')
  27.  
  28. wykop_password_input = bot.driver.find_element_by_xpath('//*[@id="newregister-pass"]')
  29. wykop_password_input.click()
  30. wykop_password_input.send_keys(f'{haslo}')
  31.  
  32. wykop_zalogujsie_btn = bot.driver.find_element_by_xpath('//*[@id="nav"]/div/ul[2]/li[4]/div/div/ul/li[1]/form/fieldset/p/input')
  33. wykop_zalogujsie_btn.click()
  34.  
  35.  
  36. while True:
  37.     try:
  38.         bot.driver.get(f'https://www.wykop.pl/ludzie/wpisy/{login}/{login}/')
  39.         text = bot.driver.find_element_by_xpath('//*[@id="itemsStream"]/li[1]/div/div/div[2]')
  40.         hover = ActionChains(bot.driver).move_to_element(text)
  41.         hover.perform()
  42.         time.sleep(1)
  43.         usun = bot.driver.find_element_by_xpath('//*[@id="itemsStream"]/li[1]/div/div/div[3]/ul/li[3]/a')
  44.         usun.click()
  45.         bot.driver.switch_to.alert.accept()
  46.     except Exception:
  47.         pass
  48.