【发布时间】:2013-11-19 11:09:07
【问题描述】:
我正在尝试编写一个 vbscript,它从具有 class 属性的 <img> 标记的 src 属性中提取值作为此 cs-poster-big
这是我迄今为止尝试过的代码,
'Initializing object with Internet Explorer Application
set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
'setting properties of Internet Explorer to the newly create object
with IE
.Visible = 0
.navigate "http://www.roku.com/channels/#!details/12" 'INSERT WEBPAGE HERE
end with
'waiting for IE to load the page
'tried using IE.busy or IE.readyState <> 4 also
while IE.busy
wScript.sleep 500
wend
wScript.sleep 500
'getting all image tags from the webpage
Set imgTags = IE.document.getElementsByTagName("IMG")
'iterating through the image tags to find the one with the class name specified
For Each imgTag In imgTags
'tried imgTag.className also
If imgTag.getAttribute("class") = "cs-poster-big" Then MsgBox "src is " & imgTag.src
next
IE.quit
set IE= Nothing
MsgBox "End of script"
它没有显示任何值,但你可以查看页面的源代码here,你可以看到它有一个<img>标签和classcs-poster-big
我不明白为什么它没有显示在我的脚本中
【问题讨论】: