如何使用 vbscript 从供应商网站提取数据?

发布于 2024-08-17 20:54:20 字数 249 浏览 2 评论 0原文

我编写了一个后映像 HTA,该映像在 XP 映像加载到计算机上后启动。 HTA 从用户收集信息(即主用户名、部门等)并根据自定义键更新注册表。管理层询问我是否可以从供应商的网站(本例中为联想)获取计算机的保修信息(特别是保修结束日期),并使用此信息更新注册表。 Lenovo 允许使用计算机类型和序列号进行匿名查找,并返回显示保修信息的页面。有没有办法使用 vbscript(或者可能是 javascript?)来解析返回的页面以获取我正在查找的数据?

提前致谢, 鳃

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你怎么敢 2024-08-24 20:54:20

使用 HTML 解析器可能是一种更可靠的方法,但使用 VBScript 很容易通过 OLE 自动化编写 Internet Explorer 脚本

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

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
云巢 2024-08-24 20:54:20

您可以相当轻松地抓取返回的页面,真正需要的只是一个 HTML 解析器,然后了解您想要的信息在返回页面中的位置。我不知道有任何 VBScript HTML 解析器,但我确信它们存在。但是,如果找不到,您可以从本地运行的代码调用外部程序,这样您就可以用任意数量的语言编写页面抓取实用程序(或使用某种 grep 实用程序),这可能会执行您的操作正在寻找。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文