我尝试使用find_elements_by_xpath从网站中提取10个元素,但是它总是提取前四个元素。
以下是我要提取的内容的屏幕截图(标有红点的行,停在标有红叉的行):
这是我的python代码:
################################################################################
# Déclaration et initialisation des variables globales
################################################################################
currentDirectory = os.getcwd()
path_to_website = "URL" #changed for stackoverflow question
path_to_chrome_profile = "path_to_chrome_profile" #changed for stackoverflow question
xpath_suggestions_text = "//li[@class='search-result search-result__occluded-item ember-view']"
################################################################################
# Navigation sur google Chrome
################################################################################
# lancement de chrome avec le profil par défaut
options_ch = webdriver.ChromeOptions()
options_ch.add_argument("user-data-dir="+path_to_chrome_profile)
browser_chrome = webdriver.Chrome(ChromeDriverManager().install(),chrome_options=options_ch)
# on va sur la page réseau de linkedIn
browser_chrome.get(path_to_website )
list_elements = browser_chrome.find_elements_by_xpath(xpath_suggestions_text)
print(len(list_elements )) #prints 4 instead of 10
for profils in list_elements :
print(element.text)
print("////////")
browser_chrome.quit()
我尝试了很多事情,但是没有任何效果。 (我是网络爬虫的初学者,请放纵:x)
谢谢大家
AJT
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。