【问题标题】:Why does rvest/html_table skip every second row in this table?为什么 rvest/html_table 跳过此表中的每一行?
【发布时间】:2020-05-21 15:55:59
【问题描述】:

我正在尝试抓取此表,但由于某种原因,每隔一行就会被跳过(这意味着我没有一半州的数据)。这是我的代码:

# read in the url
library(dplyr)
library(rvest)
webpage <- read_html ("https://oui.doleta.gov/unemploy/trigger/2013/trig_010613.html")
df <- webpage %>%
html_node("table") %>%      
html_table(fill = TRUE)  

有人知道为什么会这样吗?我唯一能想到的是每隔一行都指定了背景颜色?

谢谢:)

【问题讨论】:

    标签: html css r web-scraping rvest


    【解决方案1】:

    看看有没有帮助

    webpage <- read_html("https://oui.doleta.gov/unemploy/trigger/2013/trig_010613.html")
    df <- webpage %>%
      html_nodes(xpath = '/html/body/table') %>%      
      html_table(fill = TRUE) 
    
    
    d = as.data.frame(df)
    

    【讨论】:

    • 谢谢,但它仍然存在同样的问题,即每隔一行丢失:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 2017-08-07
    • 1970-01-01
    • 2014-06-22
    相关资源
    最近更新 更多