Posts: 7
Threads: 1
Joined: Sep 2005
The scenary is:
I will go to a web page, and view the source (from IE, it launch notepad to view the source of the web page), find character strings in the source and do things depends on what the character string says.
How could I do something like this by using QM 2.1.7?
Any help is appreciated!
Posts: 12,135
Threads: 142
Joined: Dec 2002
Better use html element functions instead of notepad.
;Test this macro with this page.
str s; int i
Htm el=htm("BODY" "" "" "View topic" 0 0 0x20)
s=el.HTML
;out s ;;uncomment this to print the html in the qm output
i=find(s "jjc51")
if i>=0
,out "found"
else
,out "not found"
Posts: 7
Threads: 1
Joined: Sep 2005
Hey, that is great! but what if the string I search for is am image, '****.gif', which I can only get from source?
Thanks a lot!
Posts: 12,135
Threads: 142
Joined: Dec 2002
this is the same source html, not just text.
Posts: 7
Threads: 1
Joined: Sep 2005
I got you, s actually contains everything in "source"
can you please explain this statement for me?
Htm el=htm("BODY" "" "" "View topic" 0 0 0x20)
especially what does "0 0 0x20" mean?
Thanks.
Posts: 12,135
Threads: 142
Joined: Dec 2002
To know more, read QM Help. But it is not necessary, because it is easier to insert this line using the Find Html Element dialog.
Posts: 7
Threads: 1
Joined: Sep 2005
Sorry for my stupid question, coz I am new to this tool :-)
what is "Find Html Element dialog" and where in QM I can find it?
Posts: 12,135
Threads: 142
Joined: Dec 2002
4-th button in the floating toolbar.
Posts: 7
Threads: 1
Joined: Sep 2005
That is very helpful! Thanks.
My web page is in Chinese, so when I drag it and get the handle, it shows up a bunch of ??????
hehe, is there a way for this tool to grep Chinese from a web page?
Posts: 12,135
Threads: 142
Joined: Dec 2002
Hey, thank you very much!
Posts: 7
Threads: 1
Joined: Sep 2005
Somehow, if the web page contains Chinese, I could not get the text...
say:
str s; int i; int j
Htm el1=htm("BODY" "" "" " Internet Explorer" 0 0 0x20)
str s1=el1.HTML
out s1
j=find(s1 "boss7.gif")
if j>=0
,out "Boss found"
else
,out "Boss not found"
I used the tool to get the html link and it can be tested in the tool. However, when I run it, I got nothing in string s1...when I print it, it has nothing :-(
is there a way to do it?
Thanks.
Posts: 7
Threads: 1
Joined: Sep 2005
the web page I tested was:
Posts: 12,135
Threads: 142
Joined: Dec 2002
The page cannot be found.
Maybe it is frameset page, and therefore does not contain BODY tag. Try to capture BODY tag in some frame. Or, capture the picture element directly.