[英]xmlTreeParse and html content
我無法使用 R 函數 xmlTreeParse 獲取(網絡抓取)html 樹內容 - 我的意思是產品的公共頁面。
我得到庫 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)
錯誤:XML 內容似乎不是 XML:'www.amazon.com/s?k=router+hand+plane+cheap&i=arts-crafts-intl-ship&ref=nb_sb_noss'
我希望抓取頁面並獲得完整的 html 結構。
在其他一些項目之后,我回到使用 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>
但是我需要在頁面上方抓取完整內容 = 我的意思是左側帶有 $ 符號的內容(這可能不是最好的直接描述)和所有標簽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.