r - I'm getting an error "cannot open the connection" when trying to scrape a website with rvest - Sta

library(tidyverse)library(rvest)fruits <- read_html(";)fruits_df <- fruits %>% html_el

library(tidyverse)
library(rvest)
fruits <- read_html(";)
fruits_df <- fruits %>% 
html_elements("._product") %>%
  map_dfr(~ tibble(
    product = .x %>% 
      html_element("._product-name-tag a") %>% 
      html_text2(), 
    price = .x %>% 
      html_element("._product-price-inner span") %>% 
      html_text2(),
    price_old = .x %>% 
      html_element("._product-price-old") %>% 
      html_text2(),
    unit = .x %>% 
      html_element("._button_unit") %>% 
      html_text2())) %>% 
  mutate(date = Sys.Date(),
         type = "Fruits and vegetables",
         source = "T MARKET", .before = product) %>% 
  mutate(price = str_replace(price, ",", "."), 
         price = parse_number(price),
         ) %>% distinct()

When running this code I'm getting the following error:

Error in open.connection(x, "rb") : cannot open the connection

Can anyone suggest a clue? Thanks!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744838181a4596391.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信