Posts: 28
Threads: 7
Joined: Apr 2016
I tried a lot to do the following:
- 1. Search for text in web page exp. "Highest Educational"
2. if there is text matches in the web page then return 1 else
3. return 0
It is like when are using Ctrl+F to find text in a web page. if there is matching return 1 else return 0.
one more note: I want to use wild card exp. search for "*Highest Educational*"
I appreciate any help.
Posts: 12,140
Threads: 142
Joined: Dec 2002
If want to get text from web browser:
Macro
Macro1727
int w=wait(3 WV win("Quick Macros Forum • View topic - Finding Text in web page - Mozilla Firefox" "MozillaWindowClass"))
Acc a.Find(w "DOCUMENT" "" "" 0x3011 3)
str s
a.WebPageProp(0 0 0 s)
;out s
if findrx(s "\bHighest Educational\b")>=0
,out 1
else
,out 0
Works with Internet Explorer and 32-bit non-portable Firefox.
---------
If want to download the web page:
Macro
Macro2701
HtmlDoc d
d.SetOptions(2)
d.InitFromWeb("http://www.quickmacros.com/forum/viewtopic.php?p=31245")
str s=d.GetText
;out s
if findrx(s "\bHighest Educational\b")>=0
,out 1
else
,out 0
Posts: 28
Threads: 7
Joined: Apr 2016
I tried it on Google Chrome and Internet Explorer. I got this
Posts: 12,140
Threads: 142
Joined: Dec 2002
The first code is for Firefox and IE. QM cannot get text from Chrome like from IE and FF, but can get with select-all-and-copy-to-clipboard.
Code for IE
Macro
Macro1727
int w=wait(3 WV win("Quick Macros Forum • View topic - Finding Text in web page - Internet Explorer" "IEFrame"))
Acc a.Find(w "PANE" "" "" 0x3001 3)
str s
a.WebPageProp(0 0 0 s)
;out s
if findrx(s "\bHighest Educational\b")>=0
,out 1
else
,out 0
For Chrome
Macro
Macro2365
int w=wait(3 WV win("Quick Macros Forum • View topic - Finding Text in web page - Google Chrome" "Chrome_WidgetWin_1"))
act w
Acc a.Find(w "DOCUMENT" "" "" 0x3001 3)
a.Select(1)
key Ca
str s.getsel
;out s
if findrx(s "\bHighest Educational\b")>=0
,out 1
else
,out 0
Or can get Chrome page URL and download the page. But it is not very useful because slow, does not work if need to log in etc.
Macro
Macro2693
int w=wait(3 WV win("Quick Macros Forum • View topic - Finding Text in web page - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.Find(w "DOCUMENT" "" "" 0x3001 3)
str URL
a.WebPageProp(URL)
HtmlDoc d
d.SetOptions(2)
d.InitFromWeb(URL)
str s=d.GetText
;out s
if findrx(s "\bHighest Educational\b")>=0
,out 1
else
,out 0
Posts: 12,140
Threads: 142
Joined: Dec 2002
Another way, works with all browsers but can be slow.
Macro
Macro2696
int w=wait(3 WV win("Quick Macros Forum • View topic - Finding Text in web page - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.Find(w "DOCUMENT" "" "" 0x3001 3)
ARRAY(Acc) k
a.GetChildObjects(k -1)
int i found
for i 0 k.len
,str s=k[i].Name; err continue
,if(s.len=0) s=k[i].Value; err continue
,if findrx(s "\bHighest Educational\b")>=0
,,found=1
,,break
out found
Posts: 3
Threads: 1
Joined: Jul 2016
Anybody know how macros can search text in site description?
Posts: 12,140
Threads: 142
Joined: Dec 2002