【发布时间】:2017-09-09 09:37:28
【问题描述】:
============
Table
============
Pagination: Link1, Link2, Link3, Link4, LinkNext,Link Last
使用选择器小工具,我发现分页位于“.pagination-container, a”中
我愿意
- 将分页中的所有链接转储到向量或data.frame
- 获取网址字符串中的最后一个数字
- 确定最大页数,指示分页中有多少页,以便稍后在抓取循环中使用它
关注http://francojc.github.io/web-scraping-with-rvest/
我从
开始library(tidyverse)
library(rvest)
url <- "https://aplikacje.nfz.gov.pl/umowy/Provider/Index?ROK=2017&OW=07&ServiceType=03&Code=&Name=&City=&Nip=&Regon=&Product=&OrthopedicSupply=false"
urls <- url %>% # feed `main.page` to the next step
html_nodes(".pagination-container, a") %>% # get the CSS nodes
html_text("href")
在 html_nodes 上会抛出错误
Error in UseMethod("xml_find_all") :
no applicable method for 'xml_find_all' applied to an object of class "character"
我做错了什么?
【问题讨论】:
-
read_html()在哪里?而且,您可能想要html_attr("href")与html_text("href")。
标签: r web-scraping rvest