【发布时间】:2021-03-13 21:29:47
【问题描述】:
我正在尝试保存在 Instagram 中喜欢我帖子的用户名
这是我的代码:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
from time import *
chrome_options = Options()
chrome_options.add_argument("--user-data-dir=chrome-data")
browser = webdriver.Chrome(options=chrome_options)
browser.get('https://www.instagram.com/p/CMAVjR5CmOx/')
continue_link = browser.find_element_by_partial_link_text('others')
continue_link.click()
elems = browser.find_elements_by_css_selector(".FPmhX.notranslate.MBL3Z")
links = [elem.get_attribute('title') for elem in elems]
WebElement = browser.find_element_by_xpath('//*[ contains (text(), ‘#’ ) ]')
WebElement.click()
browser.execute_script("arguments[0].scrollIntoView();", WebElement)
问题是,它只保存了 11 个第一个用户名,并且无法向下滚动以加载所有这些用户名
我尝试了一些代码向下滚动,但它滚动主页,而我想要滚动“关注者列表”
谁能帮我向下滚动?
我试过 "send.key" 和 "browser.execute_script("arguments[0].scrollIntoView();",Element)" 但没什么用
【问题讨论】:
-
您的问题解决了吗?
-
@vitaliis 很遗憾没有
标签: python selenium selenium-webdriver python-requests instagram