Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding Text in web page
#1
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.
#2
If want to get text from web browser:

Macro Macro1727
Code:
Copy      Help
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
Code:
Copy      Help
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
#3
I tried it on Google Chrome and Internet Explorer. I got this

[Image: QuickMacros-TextSearch-Webpage.PNG]
#4
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
Code:
Copy      Help
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
Code:
Copy      Help
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
Code:
Copy      Help
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
#5
Another way, works with all browsers but can be slow.
Macro Macro2696
Code:
Copy      Help
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
#6
Anybody know how macros can search text in site description?
#7
In web page title?


Forum Jump:


Users browsing this thread: 1 Guest(s)