开发者

How do you extract data from vendor website in vbscript?

开发者 https://www.devze.com 2022-12-16 16:23 出处:网络
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 th

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?) t开发者_如何学Goo 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


You can scrape the page that is returned fairly easily, all it really takes is an HTML parser, and then knowledge of where the information you want is located within the returned page. I do not know of any VBScript HTML parsers, but I am sure they exist. If you cannot find one, however, you can call out to an external program from locally running code, so you could write a page scraping utility in any number of languages (or use some sort of grep utility), and that may do what you are looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号