我希望能在这里得到一些帮助。我正在尝试自动从网站上下载文件,这需要我点击链接进行每次搜索。
以下是链接html信息:
(a class="icon-xls-export" href="/us/products/239505/ishares-us-consumer-goods-etf/1395165510754.ajax?fileType=csv&fileName=IYK_holdings&dataType=fund" onclick="s_objectID="https://www.ishares.com/us/products/239505/ishares-us-consumer-goods-etf/1395165510754.ajax?fileT_1";return this.s_oc?this.s_oc(e):true">
Detailed Holdings and Analytics </a)
这是我的代码:
Sub Navigate_Web()
For Each Cell In Range("A1:A1") 'location of ticker symbol
Dim IE As New InternetExplorer
IE.Visible = True
IE.Navigate "https://www.ishares.com/us/products/239505/" & Cell.Value & "?referrer=tickerSearch"
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Set objInputs = IE.document.getElementsByclassname("icon-xls-export")
Next Cell
End Sub
我可以打开网站没问题,但我一直收到对象不支持此属性或方法的错误消息。
所以这里的任何帮助都会很棒!
提前致谢!
答案 0 :(得分:0)
请正确格式化您的问题,代码块等等。)
无论如何......也许还有以下几点:
Set tags = wb.Document.GetElementsByTagname("Input")
For Each tagx In tags
If tagx.alt = "File_Certificate_Go" Then
tagx.Click
End If
Next
其中wb是WebBrowser控件。
答案 1 :(得分:0)
我想你想要这个。
Public Sub OpenWebXLS()
' *************************************************
' Define Workbook and Worksheet Variables
' *************************************************
Dim wkbMyWorkbook As Workbook
Dim wkbWebWorkbook As Workbook
Dim wksWebWorkSheet As Worksheet
Set wkbMyWorkbook = ActiveWorkbook
' *************************************************
' Open The Web Workbook
' *************************************************
Workbooks.Open ("https://www.ishares.com/us/products/239505/ishares-us-consumer-goods-etf/1395165510754.ajax?fileType=csv&fileName=IYK_holdings&dataType=fund")
' *************************************************
' Set the Web Workbook and Worksheet Variables
' *************************************************
Set wkbWebWorkbook = ActiveWorkbook
Set wksWebWorkSheet = ActiveSheet
' *************************************************
' Copy The Web Worksheet To My Workbook and Rename
' *************************************************
wksWebWorkSheet.Copy After:=wkbMyWorkbook.Sheets(Sheets.Count)
wkbMyWorkbook.Sheets(ActiveSheet.Name).Name = "MyNewWebSheet"
' *************************************************
' Close the Web Workbook
' *************************************************
wkbMyWorkbook.Activate
wkbWebWorkbook.Close
End Sub
答案 2 :(得分:0)