Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find HTML based on part of text
#1
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/viewforum.php?f=2"

Hellllp!
#2
To find object in web browser, use * in value.
Macro Macro2737
Code:
Copy      Help
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
Code:
Copy      Help
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
#3
Perfect!
Thanks a lot. Big Grin
#4
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".
#5
,if(matchw(s "*foru*"))
,,out s
,,run s
,,break
#6
Great!
Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)