简体   繁体   English

Python Selenium LinkedIn 公司网页抓取

[英]Python Selenium LinkedIn company webscraping

I'm trying to use webscraping (via Python and Selenium) to create a worksheet with companies of interest to my boss.我正在尝试使用网络抓取(通过 Python 和 Selenium)来创建一个工作表,其中包含我老板感兴趣的公司。 Most of it is working, I just can't seem to get hold of the "Next Page" button.大部分都在工作,我似乎无法抓住“下一页”按钮。 Relative and absolute XPaths, CSS selectors, nothing seems to work, since every time you generate/switch pages they're diferent.相对和绝对 XPaths、CSS 选择器,似乎都不起作用,因为每次生成/切换页面时它们都是不同的。 (The relative XPath usually is '//*[@id="ember{SOME RANDOM NUMBER}"]' ) What could I do? (相对 XPath 通常是'//*[@id="ember{SOME RANDOM NUMBER}"]' )我能做什么? There are other buttons with the same relative XPath structure in the page.页面中还有其他具有相同相对 XPath 结构的按钮。 这是我试图点击的那个该死的按钮。

The Next page button has the same XPath for all the pages. Next page按钮对所有页面都具有相同的 XPath。
It is //button[@aria-label="Next"]它是//button[@aria-label="Next"]
You should locate this element according to the aria-label attribute, not the id attribute value.您应该根据aria-label属性而不是id属性值来定位此元素。

您可以使用 class_name 函数来定位“下一个”元素

next_button = wd.find_element_by_class_name('artdeco-pagination__button next').click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM