【发布时间】:2015-08-13 00:29:37
【问题描述】:
我正在对这个网站进行网络抓取:
http://www.falabella.com.pe/falabella-pe/category/cat40536/Climatizacion?navAction=push
我只需要产品信息:“品牌”、“产品名称”、“价格”。
我可以得到,但我也可以从其他用户的类似产品的横幅中获取信息。我不需要它。
但是当我转到页面的源代码时,我看不到那些产品。我认为它是通过javascript或其他东西拉出来的:
问题 1: 在进行网络抓取时如何阻止这些信息? 这会添加我不需要的产品。但是在源码中看不到这部分。
问题 2:提取价格“precio1”时,我将其作为第一个元素:"\n\t\t\t\tSubtotal InternetS/. 0" 我在代码源中也看不到。怎么不刮呢?
library(RSelenium)
library(rvest)
#start RSelenium
checkForServer()
startServer()
remDr <- remoteDriver()
remDr$open()
#navigate to your page
remDr$navigate("http://www.falabella.com.pe/falabella-pe/category/cat40536/Climatizacion?navAction=push")
page_source<-remDr$getPageSource()
Climatizacion_marcas1 <- html(page_source[[1]])%>%
html_nodes(".marca") %>%
html_nodes("a") %>%
html_attr("title")
Climatizacion_producto1 <- html(page_source[[1]])%>%
html_nodes(".detalle") %>%
html_nodes("a") %>%
html_attr("title")
Climatizacion_precio1 <- html(page_source[[1]])%>%
html_nodes(".precio1") %>%
html_text()
【问题讨论】: