Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help on taking actions after matching a string in a file
#1
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!
#2
Better use html element functions instead of notepad.

Code:
Copy      Help
;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"
#3
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!
#4
this is the same source html, not just text.
#5
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.
#6
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.
#7
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?
#8
4-th button in the floating toolbar.
#9
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?
#10
Probably not.
#11
Hey, thank you very much!
#12
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.
#13
the web page I tested was:
#14
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.


Forum Jump:


Users browsing this thread: 1 Guest(s)