Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
167 views
in Technique[技术] by (71.8m points)

javascript - How to scroll down the LIKES (specifically) pop up window in Instagram

I'm trying to create a bot to give likes to a target audience based on a common interest but I'm having a hard time scrolling down the pop up LIKES window, here my code, at the end you'll find the piece of code I'm using to pursue such action with no success. Thank you for any leads you could provide.

Insert credentials

driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div/div/form/div/div/div/label/input").send_keys("xxxxxx")
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div/div/form/div/div[2]/div/label/input").send_keys('xxxx')
driver.find_element_by_xpath("//*[@id='react-root']/section/main/div/div/div/div/form/div/div[3]/button").click()
time.sleep(6)

Turn on notification pop up window

time.sleep(6)   
driver.find_element_by_xpath("//*[@class='mt3GC']/button").click()

Provides a hashtag & clicks in 1st hashtag that shows in pop up window

hashtag = '#xxxxxxxxx'  
driver.find_element_by_xpath("//*[@id='react-root']/section/nav/div/div/div/div[2]/input").send_keys(hashtag)     
time.sleep(6)
driver.find_element_by_xpath("//*[@id='react-root']/section/nav/div/div/div/div[2]/div/div/a").click()

Clicks in 1st pic

driver.find_element_by_xpath("//*[@id='react-root']/section/main/article/div/div/div/div/div/a/div/div[2]").click()

Clicks on the likes element of the picture

driver.find_element_by_xpath("//*[@class='Nm9Fw']/button").click()

Here the LIKES pop up window will show, only displaying 10 elements in the code, the html page will refresh as it is scrolled down changing. With the code below I'm trying to scroll down the pop up like window but it does not do anything.

scr1 = driver.find_element_by_xpath("//*[@class='_1XyCr']/div[2]/div/div/div[11]/div[2]/div/div/span/a")
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', scr1)

Any help will be highly appreciate it, I'm new to Webscraping and this is my 1st personal project.

question from:https://stackoverflow.com/questions/65931305/how-to-scroll-down-the-likes-specifically-pop-up-window-in-instagram

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...