這是我的代碼:import timefrom selenium import webdriverfrom selenium.webdriver.common.keys import Keys# loading the webpagebrowser = webdriver.Chrome()browser.get("https://instagram.com")time.sleep(1)# finding essential requirementsuser_name = browser.find_element_by_name("username")password = browser.find_element_by_name("password")login_button = browser.find_element_by_xpath("//button [@type = 'submit']")# filling out the user name boxuser_name.click()user_name.clear()user_name.send_keys("username")# filling out the password boxpassword.click()password.clear()password.send_keys("password")# clicking on the login buttonlogin_button.click()time.sleep(3)# information save permission denialnot_now_button = browser.find_element_by_xpath("//button [@class = 'sqdOP yWX7d y3zKF ']")not_now_button.click()time.sleep(3)# notification permission denialnot_now_button_2 = browser.find_element_by_xpath("//button [@class = 'aOOlW HoLwm ']")not_now_button_2.click()time.sleep(3)# finding search box and searching + going to the pagesearch_box = browser.find_element_by_xpath('//input [@placeholder="Search"]')search_box.send_keys("sb else's page")time.sleep(3)search_box.send_keys(Keys.RETURN)search_box.send_keys(Keys.RETURN)time.sleep(3)# opening ((followers)) listfollowers = browser.find_element_by_xpath('//a [@class="-nal3 "]')followers.click()time.sleep(10)# following each followerfollower = browser.find_elements_by_xpath('//button [@class="sqdOP L3NKy y3zKF "]')browser.close()在這段代碼中,我通常模擬一個普通人跟隨另一個人的行為。我想關注頁面的每個關注者。我整天都在想;但找不到任何算法。有一些好主意,但剛剛意識到我不知道如何向下滾動到列表末尾以獲取整個列表。你能幫我嗎?(如果您不明白我的意思,請嘗試運行代碼,然后提取關注者列表。)
2 回答

茅侃侃
TA貢獻1842條經驗 獲得超21個贊
# following each follower
獲取關注者列表
對于每個關注者 - 如果可能,請點擊“關注”
如果按鈕文本沒有改變,則意味著您達到了關注限制,或者可能被禁止
另外,一定要限制你的行為,instagram 有關注限制(以前是每小時 30 個),而且你可以通過 instagram API 直接獲取關注者。并且不要忘記取消關注他們,因為取消關注也有限制。接下來的電流限制是7500(以前是,現在不知道怎么樣)

jeck貓
TA貢獻1909條經驗 獲得超7個贊
首先,您需要獲取關注某人的用戶列表,然后只需在循環中執行相同的代碼即可。您可以單獨抓取用戶,也可以在 selenium 中抓取用戶。然后運行跟蹤特定人員所需的代碼,例如:for 循環。第六步:盈利
添加回答
舉報
0/150
提交
取消