Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- from time import sleep, strftime
- from random import randint
- import csv
- #Faccio login
- chromedriver_path = 'C:\Users\matteot\PycharmProjects\eng\chromedriver.exe'
- webdriver = webdriver.Chrome(executable_path=chromedriver_path)
- sleep(2)
- webdriver.get('https://www.instagram.com/accounts/login/')
- sleep(3)
- #Dati di accesso all'account
- username = webdriver.find_element_by_name('username')
- username.send_keys('tera.jessica')
- password = webdriver.find_element_by_name('password')
- password.send_keys('Ipirati96!')
- 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')
- button_login.click()
- sleep(3)
- #Ignora pop-up notifiche
- notnow = webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm')
- notnow.click()
- #Creo la lista dal file csv
- with open('lista.csv', 'rb') as f:
- reader = csv.reader(f)
- lista_utenti = list(reader)
- cont = -1
- #Metto like all'ultima foto
- for utente in lista_utenti:
- cont += 1
- webdriver.get('https://www.instagram.com/' + lista_utenti[cont] + '/')
- sleep(5)
- first_thumbnail = webdriver.find_element_by_xpath(
- '//*[@id="react-root"]/section/main/article/div[1]/div/div/div[1]/div[1]/a/div')
- button_like = webdriver.find_element_by_xpath(
- '/html/body/div[3]/div/div[2]/div/article/div[2]/section[1]/span[1]/button/span')
- button_like.click()
- sleep(randint(18, 25))
- first_thumbnail.click()
- sleep(randint(1, 2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement