Jump to content

Finding text in a html document


The_Noob
 Share

Recommended Posts

Ok so im trying to streamline a process, and have a general idea what i need to do, but am not sure exactly what needs to be done.

firstly, i know i can use $body = _IEBodyReadHTML($oIE) to read the source of an IE page, but what if autoit didnt make that page? How can i make it detect for an active IE page?

Secondly, i want the program to search for: key=x7yayxh9FOBK9KZbgq6aPoeLEs357pvq&var=. This number changes apparently randomly. I need autoit to read this number, and assign it to a value so i can use it.

Here is part of the source containing what i am looking for:

function toggle()
{
     if (toggled == 0) {
     toggled = 1;
     with (parent.bottom.document)
     {
     write('<html><head></head><body bgcolor="#000000" text="white" link="yellow" alink="orange" vlink="yellow">');
     write('<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr>');
     write('<td width=60 height=100% bgcolor="#0048BF" valign=bottom>');
     write('</td><td width="*" align=center bgcolor="#0048BF">');
     write('<font size=-2 face=verdana>Congratulations! You won the battle!<br><a href="endbattle.php?m=1::4&key=x7yayxh9FOBK9KZbgq6aPoeLEs357pvq&var=' + items[0] + ',' + items[1] + ',' + items[2] + ',' + items[3] + ',' + items[4] + ',' + items[5] + ',' + items[6] + ',' + items[7] + ',' + HP + ',' + MP + '" target="rpgmain">Click Here To Continue</a><br>( Click only once, or you may lose your experience )</font></td>');  write('<td width=60 bgcolor="#0048BF" valign=bottom>');
     write('</td></tr></table>');
     write('</body></html>');
     }
     parent.bottom.document.close();
     
     }
}

Im not sure how to isolate this with autoit, however. Could somone please help point me in the right direction?

Link to comment
Share on other sites

For the 'secondly' part...

$string = '<font size=-2 face=verdana>Congratulations! You won the battle!<br><a href="endbattle.php?m=1::4&key=x7yayxh9FOBK9KZbgq6aPoeLEs357pvq&var=and a bunch of other text'

$reg = StringRegExp($string, 'key=(.*)&var', 1)

MsgBox(0, 'Result', $reg[0])  ;may need to loop this and check per array element if multiple returns

disclaimer: I suck with stringregexp, so I'm not 100% sure if that's the best test pattern, but it works. :P

Link to comment
Share on other sites

Ok sorry dude didnt work with what i was trying to do... i tried to search StringRegExp in the help file, but didnt find anything, so im not sure exactly what its supposed to do...

http://www.rpgbattle.com

...
$body = _IEBodyReadHTML($oIE)
tooltip($body)
if StringInStr($body, "Welcome to the stadium, when you are ready click to start") Then
$body = StringSplit ($body , "&key=")
$reg = StringRegExp($body, 'key=(.*)&var', 1)
MsgBox(0,"body",$body[2])
MsgBox(0,"reg",$reg)
$key = stringsplit($body[2] , "=' + items[0] + ',' + items[1] + ',' + items[2] + ',' + items[3] + ',' + items[4] + ',' + items[5] + ',' + items[6] + ',' + items[7] + ',' + HP + ',' + MP + '")
MsgBox(0,"",$key[1])
tooltip($key[1])
...

thats the part of the code giving me problems. as you can see i like using tooltips as it easier for me to see whats actually happening. For some reason both $body and $reg return nothing. What i was thinking i could do is read the whole source from the page, cut directly to what i want, and go from there.... apparently it isnt that easy.

Edited by The_Noob
Link to comment
Share on other sites

  • Moderators

Look at _StringBetween() in the Beta help file (I don't have the new releases so I don't know if it's in there).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

And for the "first" part, look at _IEAttach

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

What xcal suggested should be correct for the "secondly" part, perhaps you messed up somewhere. Try this way:

$string = _InetGetSource("URLgoesHERE")
$reg = StringRegExp($string, 'key=(.*)&var', 3);changed the parameter to 3, i think that's correct

MsgBox(0, 'Result', $reg[0])  ;may need to loop this and check per array element if multiple returns

Try that out, hope it works *crossing fingers*

Happy Holidays,

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

firstly, i know i can use $body = _IEBodyReadHTML($oIE) to read the source of an IE page, but what if autoit didnt make that page? How can i make it detect for an active IE page?

Hmm, give more information, or explain in a different way, of what you are trying to do (perhaps an example too).

Happy Holidays,

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...