Posts: 100
Threads: 45
Joined: Jan 2014
Guys
How can i find a URL which have a specific part of text in it ?
Example:
At the URL:
http://www.quickmacros.com/
I'd like to find the URL which have "wforu" in part of it.
On this case, the macro should deliver the url "http://www.quickmacros.com/forum/vie
wforum.php?f=2"
Hellllp!
Posts: 12,092
Threads: 142
Joined: Dec 2002
To find object in web browser, use * in value.
Macro
Macro2737
int w=wait(3 WV win(" Firefox" "MozillaWindowClass"))
Acc a.Find(w "LINK" "Forum" "value=*foru*" 0x3015 3)
To find in downloaded HTML file, use HtmlDoc class.
Macro
Macro2738
out
str s
HtmlDoc d
d.SetOptions(2)
d.InitFromWeb("http://www.quickmacros.com/")
ARRAY(MSHTML.IHTMLElement) a; int i
d.GetLinks(a)
str url
for i 0 a.len
,s=a[i].getAttribute("href" 0)
,;out s
,if(matchw(s "*foru*")) out s
;d.FindHtmlElement("... ;;this could be easier but it cannot search just in href attribute
Posts: 100
Threads: 45
Joined: Jan 2014
Perfect!
Thanks a lot.
Posts: 100
Threads: 45
Joined: Jan 2014
Just one more question:
How can run or modify this url as a string?
I tried:
str s
HtmlDoc d
d.SetOptions(2)
d.InitFromWeb("http://www.quickmacros.com/")
ARRAY(MSHTML.IHTMLElement) a; int i
d.GetLinks(a)
str url
for i 0 a.len
,s=a[i].getAttribute("href" 0)
,;out s
,if(matchw(s "*foru*")) out s
run s
or
str stext.from("site" s )
But the string s is not the URL which QM is showing in "out".
Posts: 12,092
Threads: 142
Joined: Dec 2002
,if(matchw(s "*foru*"))
,,out s
,,run s
,,break
Posts: 100
Threads: 45
Joined: Jan 2014