在下面的url中

 http://www.indiavotes.com/ac/details/1/32051/216

有指向“导出到CSV”的链接,但在pagesource()中既找不到表信息也找不到download.CSV链接。
如何使用R下载此csv?

最佳答案

Sub DumpData()

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://www.indiavotes.com/ac/details/1/32051/216"

'Wait for site to fully load
IE.Navigate2 URL
Do While IE.Busy = True
   DoEvents
Loop

RowCount = 1

With Sheets("Sheet1")
   .Cells.ClearContents
   RowCount = 1
   For Each itm In IE.document.all
      .Range("A" & RowCount) = itm.tagname
      .Range("B" & RowCount) = itm.ID
      .Range("C" & RowCount) = itm.classname
      .Range("D" & RowCount) = Left(itm.innertext, 1024)

      RowCount = RowCount + 1
   Next itm
End With
End Sub

关于html - 从Web导入CSV,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32579141/

10-11 03:19