简体   繁体   English

LinkedIn抓不到全部数据

[英]LinkedIn scraping not getting all data

From a linkedin site like: https://www.linkedin.com/company/10073529?trk=tyah&trkInfo=clickedVertical%3Acompany%2CclickedEntityId%3A10073529%2Cidx%3A1-1-1%2CtarId%3A1461132316737%2Ctas%3Adastrong%20 从类似这样的linkedin网站上: https ://www.linkedin.com/company/10073529?trk = tyah & trkInfo = clickedVertical%3Acompany%2CclickedEntityId%3A10073529%2Cidx%3A1-1-1%2CtarId%3A1461132316737%2Ctas%3Adastrong%20

I am trying to retrieve 我正在尝试找回

the link associated with data-li-miniprofile-id 与data-li-miniprofile-id关联的链接

a class="new-miniprofile-container" href="..." data-li-url="..." data-li-miniprofile-id="...> 一个类=“ new-miniprofile-container” href =“ ...” data-li-url =“ ...” data-li-miniprofile-id =“ ...>

which has parents of , under , under , etc... 的上,下,下等的父项...

This is what my code looks thus far: 到目前为止,这是我的代码:

import requests
from bs4 import beautifulsoup

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.content, "html.parser")
for link in soup.find_all("a"):
    print(link.get('href'))

I initially just looked for a class="new-miniprofile-container" but it returned an empty array. 我最初只是寻找一个class =“ new-miniprofile-container”,但它返回了一个空数组。 I think the reason is that when I ran soup.prettify() (which returns all of the html scraped data), it just doesn't contain any children content after 我认为原因是当我运行soup.prettify()(返回所有html抓取的数据)时,它在之后不包含任何子内容

I feel the problem is associated with the security blocks set up by LinkedIn engineers, but I want to know if there is a way to get those URLs, or if there are any other options to get those. 我认为问题与LinkedIn工程师设置的安全块有关,但我想知道是否有办法获取这些URL,或者是否有其他选择获取这些URL。

You should be using the LinkedIn REST API instead. 您应该改用LinkedIn REST API There are the relevant company profile related endpoints and you can experiment with the REST API explorer here . 有与公司简介相关的端点,您可以在此处尝试使用REST API资源管理器。 And there is a python-linkedin client, which also has the Company API part documented. 还有一个python-linkedin客户端,其中也记录了Company API部分。

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

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