放轻松,因为我是新手。我创建了几个宏来提取搜索结果:Sec 全文搜索:http://searchwww.sec.gov/EDGARFSClient/jsp/EDGAR_MainAccess.jsp
现在我的数据已全部清理并设置在不同的列中,我需要根据结果创建一个查询。在 B 列中,我有一个公司名称列表,我想引用“B”列中的每个单元格,并在 http://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup=options+media&Country=us&Type=All 查询市场观察用于与公司名称相关的股票代码。这会对我有所帮助,因为最终我会想要执行多个查询来提取有关股份结构、收入等的信息。我将不胜感激任何时间回答这个问题。
最佳答案
试试下面的代码。
Sub website()
Dim doc As HTMLDocument
Dim htmTable As HTMLTable
Set doc = New HTMLDocument
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://www.marketwatch.com/investing/stock/BAC"
.send
Do: DoEvents: Loop Until .readyState = 4
doc.body.innerHTML = .responseText
.abort
End With
Set htmTable = doc.getElementsByClassName("companyname")(0)
If Not htmTable Is Nothing Then
MsgBox htmTable.innerText
End If
Set htmTable = doc.getElementsByClassName("lastprice")(0)
If Not htmTable Is Nothing Then
MsgBox htmTable.innerText
End If
End Sub
关于excel - 动态网页查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15868188/