以下代码将在活动工作表的单独一行中放置每个交易代码,LTP,更改和%更改。
'打开IE浏览器,导航到兴趣和循环的网站,直到满载
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://www.dsebd.org/latest_share_price_scroll_l.php"
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
如果用F12来看看源代码,你会发现每个股票和它相关的数据括号通过标记名(在本例中为“a”)。用它来收集每只股票的数据,并将所有股票的数据放在“结果”中。浏览“结果”并将每只股票放在单独的行中。使用替换功能删除换行符,以便数据显示在1行上。
Set Results = IE.document.getElementsByTagname("table")(0).getElementsByTagname("a")
x = Results.Length
For y = 0 To x - 1
gg = Results(y).innertext
gg = Replace(gg, Chr(10), "", 1, -1, vbTextCompare)
ActiveCell = gg
ActiveCell.Offset(1,0).Select
Next
来源
2013-12-12 23:51:49
ron
我能够导入点击最左边的箭头。从Excel 2010试用它 –
我已经尝试了几次与Excel 2010从'http://www.dsebd.org/latest_share_price_scroll_l.php';但其失败。 :(没有结果 – user176705
是否点击了上面我提到的最左边的箭头? –