|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Declare Function GetTickCount Lib "kernel32" () As Long
'‘http://117.21.249.37:9090/yzcg/jxyycg/search/bidCatalog.shtml?dypn=1
Sub tttt()
Dim HTML, URL, K, X, No
Cells.Clear
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set HTML = CreateObject("htmlfile")
K = 1
No = 4 '总页数
ParShow.Show 0 '进度条窗口显示
With CreateObject("msxml2.xmlhttp")
For X = 0 To No
URL = "https://http://1*.***.**1.***//flowtranslist.html?fid=10010401&mid=1001 &start=" & X
.Open "get", URL, False
.Send
DelayTime (2000) '延时,网速不好改大
HTML.body.innerhtml = .responsetext
Set tb = HTML.ALL.tags("tbody")(0)
For I = 1 To tb.Rows.Length - 1
For j = 0 To tb.Rows.Item(I).Cells.Length - 1
Cells(I + K, j + 1) = tb.Rows(I).Cells(j).innertext
Next
Next
K = K + tb.Rows.Length - 1
Set tb = Nothing
ParShow.LblNote.Caption = "正在抓取第" & X & "页!!"
ParShow.lblProgress.Width = Int((X / No) * ParShow.lblBack.Width) '标签宽度
ParShow.lblPercent.Caption = Format(Int((X / No) * 100), "0") & "%" '完成百分比
'ParShow.Repaint '窗体重绘
DoEvents
Next X
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Set tb = Nothing
Unload ParShow
MsgBox "数据抓取完成!"
End With
End Sub
Sub DelayTime(DTime As Long) '延时
SaveTime = GetTickCount
While GetTickCount < SaveTime + DTime '等待1S
DoEvents
Wend
End Sub
运行到.send就提示错误,应该是需要用户名和密码的原因,怎么改? |
|