如何使用 vbscript 剥离元素并显示在消息框中? [英] How can I strip the element using vbscript and display in message box?

查看:12
本文介绍了如何使用 vbscript 剥离元素并显示在消息框中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到 2 年合同的价格并将其显示在消息框中.到目前为止我有:

I would like to find the price with 2 year contract and display it in a message box. Sofar I have:

Dim MyPage
Dim Price
Set MyPage=CreateObject("Microsoft.XMLDOM")
MyPage.load("http://www.verizonwireless.com/b2c/store/controller?item=phoneFirst&action=viewPhoneDetail&selectedPhoneId=5723")
Wscript.Sleep 2000
Set Price = MyPage.getElementsByTagName("span")
For Each Elem In Price
   MsgBox(Elem.firstChild.nodeValue) 
Next

我知道我完全错了,但我什至不知道从哪里开始.我喜欢编写这样的简单程序,但我只需要入门帮助.任何想法都会有所帮助!

I understand that I am completely wrong, but I don't even know where to start. I love writing simple programs like this, but I just need help getting started. Any ideas will help!

推荐答案

这里有一个更好的版本,使用 HTMLFile 对象

Here a better version, uses the HTMLFile object

Dim HTMLDoc, XML, URL, table
Set HTMLDoc = CreateObject("HTMLFile")
Set XML = CreateObject("MSXML2.XMLHTTP")
URL = "http://www.verizonwireless.com/b2c/store/controller?item=phoneFirst&action=viewPhoneDetail&selectedPhoneId=5723"

With XML
  .Open "GET", URL, False
  .Send
  HTMLDoc.Write .responseText
End With

Set spans = HTMLDoc.getElementsByTagName("span")
for each span in spans
  WScript.Echo span.innerHTML
next

'=><SPAN>Set Location</SPAN>
'=>Set Location
'=><SPAN>Submit</SPAN>
'=>Submit
'=>Connect with us

这篇关于如何使用 vbscript 剥离元素并显示在消息框中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆