excel - 动态网页查询

标签 excel vba

放轻松,因为我是新手。我创建了几个宏来提取搜索结果: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/

相关文章:

excel - 在用户窗体 VBA 中使用带有选项按钮的 IF/Then 语句

excel - 当单元格值被清除时如何触发代码?

excel - 从 Excel 中的范围中提取唯一值

javascript - 将 html 内容导出到 javascript 中的 excel

vba - 在 VBA 中,如何在不将鼠标悬停在变量上的情况下查看变量的值?

r - 从 PowerPivot 导出数据

vba - Excel VBA : Delete row if Column A contains a number within the string

vba - 我可以从 MS Access 中运行带有 SQL Server 查询的 CurrentDb.Execute 吗?

excel - 从 Excel 批量插入到 SQLite,无需 TXT 或 CSV 文件

Excel VBA - 获取图表数据范围