Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.keys import Keys
  3. from time import sleep, strftime
  4. from random import randint
  5. import csv
  6.  
  7. #Faccio login
  8. chromedriver_path = 'C:\Users\matteot\PycharmProjects\eng\chromedriver.exe'
  9. webdriver = webdriver.Chrome(executable_path=chromedriver_path)
  10. sleep(2)
  11. webdriver.get('https://www.instagram.com/accounts/login/')
  12. sleep(3)
  13. #Dati di accesso all'account
  14. username = webdriver.find_element_by_name('username')
  15. username.send_keys('tera.jessica')
  16. password = webdriver.find_element_by_name('password')
  17. password.send_keys('Ipirati96!')
  18.  
  19. button_login = webdriver.find_element_by_css_selector('#react-root > section > main > div > article > div > div:nth-child(1) > div > form > div.Igw0E.IwRSH.eGOV_._4EzTm.bkEs3.CovQj.jKUp7.DhRcB > button > div')
  20. button_login.click()
  21. sleep(3)
  22.  
  23. #Ignora pop-up notifiche
  24. notnow = webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
  25. notnow.click()
  26.  
  27. #Creo la lista dal file csv
  28. with open('lista.csv', 'rb') as f:
  29.     reader = csv.reader(f)
  30.     lista_utenti = list(reader)
  31.  
  32. cont = -1
  33. #Metto like all'ultima foto
  34. for utente in lista_utenti:
  35.     cont += 1
  36.     webdriver.get('https://www.instagram.com/' + lista_utenti[cont] + '/')
  37.     sleep(5)
  38.     first_thumbnail = webdriver.find_element_by_xpath(
  39.         '//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[1]/a/div')
  40.     button_like = webdriver.find_element_by_xpath(
  41.         '/html/body/div[3]/div/div[2]/div/article/div[2]/section[1]/span[1]/button/span')
  42.     button_like.click()
  43.     sleep(randint(18, 25))
  44.     first_thumbnail.click()
  45.     sleep(randint(1, 2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement