问题描述
我已经安装了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