【发布时间】:2021-10-28 13:41:29
【问题描述】:
我在抓取不同货币的值时遇到了问题。例如,以下网站以美元提供了有关项目成本的信息,我可以抓取它:https://indiainvestmentgrid.gov.in/opportunities/project/21117。但是,也可以选择成本货币(在右上角),我想在 IND 中抓取此信息。您对如何访问它有什么建议吗?也许有可能用 RSelenium 做点什么?
library(rvest)
library(RSelenium)
url <- read_html("https://indiainvestmentgrid.gov.in/opportunities/project/21117")
project_total_cost <- url %>%
html_nodes(".total-cost-value") %>%
html_text()
project_total_cost
"USD 387.24 mn"
【问题讨论】:
-
浏览下拉菜单是可能的,但价格昂贵 - 每页大约需要 3 秒才能可靠地获取它。在这种情况下,我认为您最好像现在一样使用
rvest进行抓取,然后使用汇率进行转换,或者如果您坚持使用RSelenium,将值设置为IND 一次,然后所有后续您在该会话中打开的页面应使用 IND 显示。 -
知道了,我想知道是否有可能以某种方式自动制作,也许您可以简要描述一下我如何通过下拉菜单(即使它很昂贵)?
-
在下拉菜单中找到每个阶段的css或选择器,然后点击。 IE。
remDr$findElement("css selector", "#select_country")>webElem$clickElement()>remDr$findElement(...)等coderedirect.com/questions/238345/… 有一些示例说明如何做到这一点。
标签: r web-scraping rvest rselenium