Instagram automation using selenium python code
from selenium import webdriver
import time
from random import seed
from random import randint
from selenium.webdriver import Keys
def getRandomTime():
randTime = randint(3, 5)
return randTime
username = "03184750663"
password = "samiikhan123"
driver = webdriver.Chrome("E://driver//chromedriver.exe")
driver.get("https://instagram.com")
time.sleep(getRandomTime())
driver.find_element("xpath","//input[@name=\"username\"]") \
.send_keys(username)
driver.find_element("xpath","//input[@name=\"password\"]") \
.send_keys(password)
time.sleep(getRandomTime())
driver.find_element("xpath",'//button[@type="submit"]') \
.click()
time.sleep(getRandomTime())
driver.find_element("xpath","//button[contains(text(),'Not Now')]") \
.click()
time.sleep(getRandomTime())
driver.find_element("xpath","//button[contains(text(),'Not Now')]") \
.click()
time.sleep(getRandomTime())
search2 = driver.find_element("xpath","//span[text(),'Search']")
search2.send_keys('duck._lover')
count=0
while count < 3:
search2.send_keys(Keys.Enter)
count +=1
time.sleep(1)
time.sleep(getRandomTime())
driver.find_element("xpath","//button[contains(text(),'Follow')]") \
.click()
The main strategy behind this is using the automated browsing tools that Selenium provides to log onto your account on the Instagram website, navigate past all of those annoying pop-ups, search the profile of some famous high profile people and just start following people that follow them randomly.
I put random time delays between most of the actions to simulate the randomness of a human user using the website and try and avoid Instagram’s bot detection algorithms.
I hope You really enjoyed this blog . I try my best to make every thing is easy and helpfull to provide to public .You will get more blog about the Programing project and code . Thanks for visiting my blog if you have any querry related to this you can comment here i will try my best to response you back
0 Comments