在网页查询中查找string,而不在网页上放置网页内容
我在一个macros中有一个webquery。
.Refresh BackgroundQuery:=False
上面的行将网页内容放在活动工作表中。 然后我find一个string“批准”与下面给出的代码
Set findRng = Cells.Find(What:="approved", After:=ActiveCell, _ LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
如果findstring,我会用下面给出的代码做一些工作
If Not findRng Is Nothing Then 'do some job End If
我可以find直接从内存或某种arraysapproved
的单词,而不会将网页的内容放在表格中,如果是的话,怎么样?
Function GetResponseText(url as String) as String Dim objHttp As Object objHttp = CreateObject("MSXML2.ServerXMLHTTP") objHttp.Open("GET", url, False) objHttp.Send("") GetResponseText = objHttp.ResponseText End Function
GetResponseText包含html文本(完整脚本)search:
If instr(GetResponseText([your url]), "approved") > 1 Then 'your code if approved Else 'your code if not End If
你可以检查'GetResponseText'string并search“> approved <”或类似的东西