VBscript (screen scraping) broken in IE8
Wrote a vbscript to get fedex quotes. Works great in IE6 however in IE8 (any mode) breaks with a Error: Object required: 'element' Code: 800A01A8
I am stumped here is the code:
dim ie1
dim wsh : Set wsh = CreateObject("WScript.Sh开发者_Python百科ell")
Dim ArgObj, var1, var2, var3, var4: Set ArgObj = WScript.Arguments
var1 = 2.5 'ArgObj(0) 'First parameter
var2 = 2.5 'ArgObj(1) 'Second parameter
var3 = 2.5 'ArgObj(2) 'Third parameter
var4 = 2.5 'ArgObj(3) 'Fourth parameter
dim zip
zip=InputBox("Please enter destination zip code - You must have Internet access for this to work", " Destination Zip Code", 12345)
Const URL = "https://www.fedex.com/ratefinder/home?cc=US&language=en&locId="
set ie1=WScript.CreateObject("InternetExplorer.Application")
with ie1
.Visible =1
'dim wsh : Set wsh= CreateObject( "WScript.Shell" )
'dim iefocus
'Do Until iefocus
'iefocus=wsh.AppActivate("Microsoft Internet Explorer")
'Loop
.Navigate URL
Do Until .ReadyState = 4
WScript.Sleep 50 ' wait for page to load
Loop
On Error resume next
With .document.forms("logonForm")
.username.value = "" ' enter company into a textbox
.password.value = "" ' enter name into a textbox
.submit
WScript.Sleep 100 ' wait for page to load
Do Until ie1.busy=0
WScript.Sleep 50 ' wait for page to load
Loop
End With
On Error Goto 0
With ie1.document.forms("standAloneActionForm")
.origZip.value = "84016"
.destZip.value=zip
.receivedAtCode.value=1
.totalPackageWeight.value=var1
For Each element in .elements
If element.type = "button" and element.value="Get detailed quote" Then
element.click
End If
Next
WScript.Sleep 500 ' wait for page to load
Do Until ie1.busy=false
WScript.Sleep 50 ' wait for page to load
Loop
With ie1.document.forms("standAloneActionForm")
For Each element in .elements
If element.type = "text" Then
'.if element.value="Select" then element.value.selectedindex=1
if element.value="L" then element.value=var2
if element.value="W" then element.value=var3
if element.value="H" then element.value=var4
End If
Next
With ie1.document.forms("PackageList")
' .packageType.value=1
' For Each element in .elements
If element.type = "Select" Then
.packageType.value=1
'if element.value="Select" then element.value=1
End If
' Next
' For Each element in .elements
If element.type = "button" and element.value="Continue" Then
element.click
End If
' Next
end with
end with
end with
end with
It breaks right after "PackageList" Which is a dropdown box.
Any ideas would help.
精彩评论