[英]xmlTreeParse and html content
I can't get (web scrape) html tree content with R function xmlTreeParse - I mean common page with products.我无法使用 R 函数 xmlTreeParse 获取(网络抓取)html 树内容 - 我的意思是产品的公共页面。
I get library Rcurl and XML.我得到库 Rcurl 和 XML。
myurln3<-"www.amazon.com/s?k=router+hand+plane+cheap&i=arts-crafts-intl-ship&ref=nb_sb_noss"
html_page<-xmlTreeParse(myurln3, useInternalNodes = TRUE)
Error: XML content does not seem to be XML: 'www.amazon.com/s?k=router+hand+plane+cheap&i=arts-crafts-intl-ship&ref=nb_sb_noss'
错误:XML 内容似乎不是 XML:'www.amazon.com/s?k=router+hand+plane+cheap&i=arts-crafts-intl-ship&ref=nb_sb_noss'
I expect to scrape page and get full html structure.我希望抓取页面并获得完整的 html 结构。
I back after some other projects to web scraping with R and still with problems.在其他一些项目之后,我回到使用 R 进行网络抓取,但仍然存在问题。
> library(XML)
Warning message:
XML package is in R 3.5.3 version
> my_url99 <- "https://www.amazon.com/s?k=Dell+laptop+windows+10&ref=nb_sb_noss_2"
> html_page99 <- htmlTreeParse(my_url99, useInternalNode=TRUE)
Warning message:
XML content does not seem to be XML: 'https://www.amazon.com/s?k=Dell+laptop+windows+10&ref=nb_sb_noss_2'
> head(html_page99)
Error in `[.XMLInternalDocument`(x, seq_len(n)) :
No method for subsetting an XMLInternalDocument with integer
> html_page99
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><p>https://www.amazon.com/s?k=Dell+laptop+windows+10&ref=nb_sb_noss_2</p></body></html>
But I need to scrape above page with full content = I mean content with $ sign on the left (fmaybe that's not the best direct description) and all the tags.但是我需要在页面上方抓取完整内容 = 我的意思是左侧带有 $ 符号的内容(这可能不是最好的直接描述)和所有标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.