【发布时间】:2015-05-12 15:18:20
【问题描述】:
我正在使用 R 进行网页抓取。我需要的信息在this webpage.的链接中 但是当我单击时,链接会转到我所在的同一页面。如何在这些其他链接之后抓取信息,直到获得包含所需信息的表格?几个月前我开始使用 R,我知道 httr、Curl 和其他包,但我无法抓取这个网页。我需要这样的输出(通过单击“Todo el territorio”和 Tipo de estudios:“Bachillerato”):
Provincia|Localidad|Denominacion Generica|Denominacion Especifica|Codigo|Naturaleza
Almería|Adra|Instituto de Educación Secundaria|Abdera|04000110|Centro público
Almería|Adra|Instituto de Educación Secundaria|Gaviota|04000134|Centro público
...
这将是我使用 Selenium 包的一般脚本,但它不起作用,我接受任何选项:
library(RSelenium)
library(XML)
library(magrittr)
RSelenium::checkForServer()
RSelenium::startServer()
remDrv <- RSelenium::remoteDriver(remoteServerAddr = "localhost", port = 4444, browserName = "chrome")
remDrv$open()
remDrv$navigate('https://www.educacion.gob.es/centros/selectaut.do')
remDrv$findElement(using = "xpath", "//select[@name = '.listado-inicio']/option[@value = ('02','00')]")$clickElement()
...
或类似的东西。我在 stackoverflow 中找到了与此脚本类似的东西来寻找其他主题,但我什么也没得到。我接受其他脚本的其他解决方案。 非常感谢。
【问题讨论】:
-
您能展示一下您目前使用的代码吗?
标签: javascript r web web-scraping