在网页查询中找到一个字符串,而不会在页面上放置网页内容 [英] Find a string in web query without putting webpage contents on the sheet
问题描述
.Refresh BackgroundQuery:= False
上述行将网页内容放在活动工作表中。然后我找到一个字符串批准,代码如下
Set findRng = Cells.Find(What:=approved ,After:= ActiveCell,_
LookIn:= xlFormulas,LookAt:= xlPart,SearchOrder:= xlByRows,_
SearchDirection:= xlNext,MatchCase:= False,SearchFormat:= False)
如果找到字符串,我可以用下面的代码做一些工作
If Not findRng is Nothing然后
'做一些工作
结束如果
我可以从内存或某种数组中直接找到批准的
,而不将网页的内容放在工作表中如果是,那么如何?
函数GetResponseText(url as String)as String
Dim objHttp As Object
objHttp = CreateObject(MSXML2.ServerXMLHTTP)
objHttp.Open(GET,url,False)
objHttp.Send()
GetResponseText = objHttp.ResponseText
结束F unction
GetResponseText包含html作为文本(完整脚本)
搜索:
如果instr(GetResponseText([your url])),approved)> 1然后
'你的代码如果被批准
Else
'你的代码,如果不是
结束如果
您可以检查GetResponseText字符串,并搜索>已批准或类似的
I have a webquery within a macro.
.Refresh BackgroundQuery:=False
The above line puts the webpage contents in the active worksheet. Then I find a string "approved" with the code given below
Set findRng = Cells.Find(What:="approved", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If the string is found, I do some job with the code given below
If Not findRng Is Nothing Then
'do some job
End If
Can I find the word approved
directly from memory or some kind of array without putting the contents of the webpage in the sheet and if yes, how?
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 contains the html as text (full scripting) search with:
If instr(GetResponseText([your url]), "approved") > 1 Then
'your code if approved
Else
'your code if not
End If
you may check the string of 'GetResponseText' and search for ">approved<" or something like that
这篇关于在网页查询中找到一个字符串,而不会在页面上放置网页内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!