|
工作需要前2天制作了这个工具去网页上抓取数据,之前也碰到同样的问题,后又高人指点可能是cookie的问题,清除后就好用了。昨天下午开始又碰到同样的问题了,清理cookie也没用,有没有大神可以指点一下问题出在那里,怎么解决?
PS:登陆不需要密码点游客登陆就可以了。
Private Sub capture()
Dim wksmainsheet As Worksheet
Dim lngmainsheetrows As Long
Dim ie, dmt, tbs, i&, tb
Set wksmainsheet = ActiveWorkbook.Worksheets("Shipment")
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "http://210.13.100.102/scs/Web/Pages/signin.aspx"
Do Until .ReadyState = 4
DoEvents
Loop
Set dmt = .document
dmt.all("hrefVisitor").Click
Sleep 3000
Do Until .ReadyState = 4 And ie.busy = False
DoEvents
Loop
lngmainsheetrows = 2
Do While wksmainsheet.Cells(lngmainsheetrows, 1) <> 0
Do Until .ReadyState = 4 And ie.busy = False
DoEvents
Loop
'Set dmt = .document
dmt.all("_ctl0_ContentPlaceHolderMain_txtNum").Value = wksmainsheet.Cells(lngmainsheetrows, 1)
'dmt.all("_ctl0:ContentPlaceHolderMain:txtNum").Value = wksmainsheet.Cells(lngmainsheetrows, 1)
dmt.all("_ctl0_ContentPlaceHolderMain_btnSearch").Click
Do Until .ReadyState = 4 And ie.busy = False
DoEvents
Loop
'MsgBox dmt.all("_ctl0_ContentPlaceHolderMain_txtNum").Value
wksmainsheet.Cells(lngmainsheetrows, 2) = dmt.all("_ctl0_ContentPlaceHolderMain_lblResult").innertext
x = InStr(wksmainsheet.Cells(lngmainsheetrows, 2), wksmainsheet.Cells(lngmainsheetrows, 1))
lngmainsheetrows = lngmainsheetrows + 1
Loop
End With
ie.Quit
End Sub
|
|