VBA Selenium没有将数据的第一列返回到Excel

问题描述

我已经安装了Selenium,所有功能都可以正常工作,只是没有从站点返回并在Excel中发布第一列数据。我敢肯定这很简单。任何人,请帮助。

df2 = (df.set_index('ID')[['Manager1','Manager2','Manager3']]
         .stack()
         .reset_index(level=1,drop=True)
         .reset_index(name='Manager'))

print (df2)
   ID  Manager
0   1  S394[1]
1   1  G490[2]
2   1  3004[3]
3   2  3905[1]
4   2  4003[2]
5   2  5003[3]

解决方法

我没有Selenium,但这是使用IE自动化的基本轮廓:

    Dim Explorer As Object,doc,tbls,tr,td
    Set Explorer = GetIEByUrl("https://www.cmegroup.com/trading*") 'function to get an open window by URL
    
    Set doc = Explorer.document
    
    Set tbls = doc.getElementsByTagName("table")
    'look at the first table: get the rows in the table body
    For Each tr In tbls(0).getElementsByTagName("tbody") (0).getElementsByTagName("tr")
        'the first cell is a th
        Debug.Print tr.getElementsByTagName("th")(0).innerText
        'the rest of the cells are td's
        For Each td In tr.getElementsByTagName("td")
            Debug.Print td.innerText
        Next td
        Debug.Print "***********************"
    Next tr

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...