vbs 网页 判断 字符 点击链接
http://news.baidu.com/ns?word=%CD%AC%CE%BB%CB%D8%B7%C5%C9%E4%D0%D4%B0%B2%C8%AB%B9%E6%B6%A8%CC%F5%C0%FD&tn=newsB&from=news&ie=gb2312&bs=%CD%AC%CE%BB%CB%D8%B7%C5%C9%E4%D0%D4%B0%B2%C8%AB%B9%E6%B6%A8&sr=0&cl=2&rn=20&ct=1&prevct=no
vbs如何根据页面结果,判断篇数(怎么判断是7篇),并依次点击7篇的链接。
[解决办法]
这个要自己仔细分析网页源码,根据不同结果分别处理。
如果你正则用得还行,可以采用楼上的提议,用Microsoft.XMLHTTP得到HTML源码,然后正则来获取结果。
Set oIE = CreateObject("InternetExplorer.Application") oIE.Visible = 1 oIE.Navigate "http://news.baidu.com/ns?word=%CD%AC%CE%BB%CB%D8%B7%C5%C9%E4%D0%D4%B0%B2%C8%AB%B9%E6%B6%A8%CC%F5%C0%FD&tn=newsB&from=news&ie=gb2312&bs=%CD%AC%CE%BB%CB%D8%B7%C5%C9%E4%D0%D4%B0%B2%C8%AB%B9%E6%B6%A8&sr=0&cl=2&rn=20&ct=1&prevct=no" Do WScript.Sleep 200 Loop Until Not oIE.Busy And oIE.ReadyState = 4' For Each x In oIE.Document.all.tags("a")' WScript.Echo i & vbTab & x.innerText ' Next' WScript.Echo oIE.Document.all.tags("table")(10).innerText WScript.Echo oIE.Document.getElementsByTagName("table")(2).innerTextSet a_Elements = oIE.Document.getElementsByTagName("a")For Each x In a_Elements strOut = strOut & x.innerText & vbTab & x.href & vbCrLfNext WScript.Echo strOut oIE.Quit WScript.Quit
[解决办法]