偶尔需要用百度爬点数据,下面展示如何用关键字在百度搜索,抓取相关信息

## 百度搜索接口
"http://www.baidu.com.cn/s?wd=" + key + "&cl=3"

library(rvest)
library(magrittr)
library(xml2)
library(htmltools)
library(stringr)

key <- '宝马'
key%>%HTML()%>%URLencode()%>%paste0("http://www.baidu.com.cn/s?wd=",.,"&cl=3")%>%
    read_html()%>%html_nodes('h3 a')%>%html_text()

以上

相关文章:

  • 2021-11-20
  • 2021-05-13
  • 2021-05-17
  • 2022-01-02
  • 2021-09-04
  • 2021-09-25
  • 2022-02-13
  • 2022-01-18
猜你喜欢
  • 2021-11-08
  • 2021-12-06
  • 2022-12-23
  • 2021-06-04
  • 2021-07-01
  • 2021-05-27
相关资源
相似解决方案