【问题标题】:R: LinkedIn scraping using rvestR:LinkedIn 使用 rvest 抓取
【发布时间】:2015-10-31 23:18:57
【问题描述】:

使用rvest 包,我正在尝试从我的LinkedIn profile 中抓取数据。

这些尝试:

library(rvest)
url = "https://www.linkedin.com/profile/view?id=AAIAAAFqgUsBB2262LNIUKpTcr0cF_ekoX9ZJh0&trk=nav_responsive_tab_profile"
li = read_html(url)
html_nodes(li, "#experience-316254584-view span.field-text")
html_nodes(li, xpath='//*[@id="experience-610617015-view"]/p/span/text()')

没有找到任何节点:

#> {xml_nodeset (0)}

问:如何只返回文本?

#> "Quantitative hedge fund manager selection for $650m portfolio of alternative investments"

编辑:

LinkedIn 有一个 API,但由于某种原因,下面只返回前两个经验职位,没有其他项目(如教育、项目)。因此采用了抓取方法。

library("Rlinkedin")
auth = inOAuth(application_name, consumer_key, consumer_secret)
getProfile(auth, connections = FALSE, id = NULL) # returns very limited data

【问题讨论】:

  • html_text 但LinkedIn也有一个API,所以你真的不需要刮。

标签: r web-scraping rvest


【解决方案1】:

您让事情变得不必要地困难......您需要做的就是在从 Linkedin 获得 OAuth 2.0 令牌后向https://api.linkedin.com/v1/people/~?format=json 发出 GET 请求。在 R 中,您可以使用 jsonlite

library(jsonlite)
linkedin <- fromJSON('https://api.linkedin.com/v1/people/~?format=json')
position <- linkedin$headline

您必须对您的 oauth 令牌拥有“r_basicprofile”成员权限。

【讨论】:

  • 这是可能评论
  • 我已经包含了 API try,它返回有限的数据。因此刮。
猜你喜欢
  • 2020-07-18
  • 2023-01-07
  • 2020-07-18
  • 2019-02-17
  • 2017-06-26
  • 2018-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多