使用RSelenium在R中提交java表单
我正在尝试使用RSelenium在这里发布一个表单http://www.censusindia.gov.in/Census_Data_2001/Village_Directory/View_data/Village_Profile.aspx
我可以从下拉菜单中收集所有的值,但我不知道如何提交表单来检索表数据
我试过很多命令
#Setting up the proxy server
RSelenium::checkForServer()
#Openning the Remote Driver
remDr <- remoteDriver$new()
remDr$open()
remDr$setImplicitWaitTimeout(3000)
remDr$navigate("http://www.censusindia.gov.in/Census_Data_2001/Village_Directory/View_data/Village_Profile.aspx")
stateElem <- remDr$findElement(using = "name", "ctl00$Body_Content$drpState")
stateElem$setElementAttribute(value = "18") #for state "Assam"
及
remDr$executeScript("document.forms[0].submit();", list(value = "18"))
以及
document.forms["aspnetForm"].elements["stateElem"].value = "18"
我希望能够在选定州的地区、街道和村庄中运行这个循环
我知道我在这里没有给社区提供太多的合作机会,但我对RSelenium和java还不熟悉
提前谢谢
# 1 楼答案
我和一位朋友(痛苦地)用Python找到了这个问题的解决方案。我仍然很想学习一种用R完成类似任务的方法。下面是代码:
我对Python非常陌生,更喜欢使用R来完成这项任务。这可能吗