这不符合堆叠溢出政策,因为我没有显示我做了什么,但我真的不知道如何开始这个问题,因为我缺乏技术专长。希望有人能贴出一个解决方案,或者至少给我指明正确的方向。
我想从这个网站下载所有数据:
Report1.aspx
我需要下载所有的数据,即所有季节*全年*所有州*所有作物。时间越长(令人沮丧!)方法是点击所有的盒子,然后按下下载。
然而,我想知道是否有人有任何编程解决方案来下载这些数据。我最好在R中这样做,因为这是我理解的语言,但可以随意标记其他编程语言。
发布于 2017-10-04 20:33:18
这里有一个解决方案,使用RSelenium实例浏览器并指导它执行您的命令。
library(RSelenium)
driver <- rsDriver()
remDr <- driver[["client"]]
remDr$navigate("http://aps.dac.gov.in/APY/Public_Report1.aspx") #navigate to your page基本上,您需要告诉浏览器选择要标记的每个按钮,使用SelectorGadget查找每个按钮的唯一ID,然后一个接一个地将它们传递给webElem。然后使用webElem方法让页面做一些事情。
webElem <- remDr$findElement(using = 'id', value = "TreeViewSeasonn0CheckBox")
webElem$highlightElement() #quick flash as a check we're in the right box
webElem$clickElement() #performs the click
#now do the same for each other box
webElem <- remDr$findElement(using = 'id', value = "TreeView1n0CheckBox")
webElem$highlightElement()
webElem$clickElement()
webElem <- remDr$findElement(using = 'id', value = "TreeView2n0CheckBox")
webElem$highlightElement()
webElem$clickElement()
webElem <- remDr$findElement(using = 'id', value = "TreeViewYearn0CheckBox")
webElem$highlightElement()
webElem$clickElement()现在选择所需的报表并单击“下载”按钮。假设这里是Excel格式。
webElem <- remDr$findElement(using = 'id', value = "DdlFormat")
webElem$sendKeysToElement(list("Excel", key = "enter"))
webElem <- remDr$findElement(using = 'id', value = "Button1")
webElem$clickElement() #does the click至于它的价值,网站超时试图下载所有的数据给我。你的结果可能会有所不同。
https://stackoverflow.com/questions/46569481
复制相似问题