我想从url:chrome中的目标图链接xpath https://tophatter.com/lots/104461372下载一张图片
提取:
https://images.tophatter.com/42c09f609e7a6a47c70e0e1ccf3a0bb6/large.jpg
虽然xpath不起作用: divclass='col-md-7时隙-映像‘img 在Chrome > the >单击大图中,Xpath显示在: //*@id="lot-modal-content"/div1/img中
它在xml主体部分,没有在rvest教程中使用
library(rvest)
library(downloader)
library(dplyr)
url <- "https://tophatter.com/lots/104461372"
doc <- read_html(url)
doc <- xml2::read_html(url)
doc %>% html_nodes("div.col-md-7") %>% html_attr("class")
doc %>% html_nodes("div.col-md-7") %>% html_attr("src")以下是返回'col-md-7插槽-图像‘的NA。
发布于 2019-04-28 08:11:58
在这里我的解决方案,经过跟踪和错误,我发现目标jpg url在头部部分。
a = doc %>% html_nodes("meta") %>% html_attrs
a = doc %>% html_nodes("meta") %>% html_attr("content") %>% na.omit
index = a %>% stringr::str_detect(".jpg") %>% which
a[index]https://stackoverflow.com/questions/55888141
复制相似问题