如何从vbscript中的供应商网站提取数据? [英] How do you extract data from vendor website in vbscript?
问题描述
我已经编制了一张后映像HTA,它在XP映像加载到计算机后启动。 HTA从用户收集信息(即主要用户名,部门等)并根据自定义密钥更新注册表。管理层询问我是否可以从供应商的网站(本例中为联想)提取计算机的保修信息(特别是保修结束日期),并使用此信息更新注册表。 Lenovo允许使用计算机类型和序列号进行匿名查询,并返回显示保修信息的页面。有没有一种方法使用VBScript(或可能是JavaScript?)来解析返回的页面中的数据,我正在寻找?
在此先感谢,
Gill 使用HTML解析器可能会更健壮地完成这项工作,但VBScript很容易<
Dim ie,frm
Set ie = CreateObject(InternetExplorer.Application)
ie.Visible = True
ie.Navigatehttp://www-307.ibm.com/pc/support/site.wss/& _
document.do?lndocid=LOOK-WARNTY#sw
直到ie.ReadyState = 4''READYSTATE_COMPLETE
WScript.Sleep 100
循环
Set frm = ie.Document.Forms.warrantyLookup
frm.type.Value =2644
frm.serial.Value =23AB123
frm.Submit
Do直到ie.Document.ReadyState =完成
WScript.Sleep 100
循环
''找到您想从$ b $中刮取的信息b''即.Document DOM在这一点上
ie.Quit
I have programmed a post image HTA which is launched after an XP image has been loaded onto a computer. The HTA gathers information from the user (ie primary user name, department, etc) and updates the registry under a custom key. Management has asked if I can pull the computer's warranty information (specifically the warranty end date) from the vendor's website (in this case Lenovo) and update the registry with this info. Lenovo allows anonymous lookup using computer type and serial number and returns a page showing warranty information. Is there a way using vbscript (or maybe javascript?) to parse the returned page for the data I'm looking for?
Thanks in advance, Gill
Using an HTML parser would probably be a more robust way to do this, but it's easy with VBScript to just script Internet Explorer through OLE Automation.
Dim ie, frm
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www-307.ibm.com/pc/support/site.wss/" & _
"document.do?lndocid=LOOK-WARNTY#sw"
Do Until ie.ReadyState = 4 '' READYSTATE_COMPLETE
WScript.Sleep 100
Loop
Set frm = ie.Document.Forms.warrantyLookup
frm.type.Value = "2644"
frm.serial.Value = "23AB123"
frm.Submit
Do Until ie.Document.ReadyState = "complete"
WScript.Sleep 100
Loop
'' Locate the information you want to scrape from the
'' ie.Document DOM at this point
ie.Quit
这篇关于如何从vbscript中的供应商网站提取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!