mIRC Home    About    Download    Register    News    Help

Print Thread
#174987 15/04/07 01:59 PM
S
Stefan_Leroux
Stefan_Leroux
S
Hey Guys, I'm looking for a bit of help with setting variables.

I'm trying to make a script to check my status on a web page.

The web page displays in this format

<div class="divclass">info goes in here</div><div class="divclass2">more info goes in here</div>

I have already created a script to obtain the html from the page, but I need some way to set the information into variables. I need to know if its possible to set a variable starting after the <div class="divclass"> and ending at the </div>, or even to set the entire variable and $remove the div classes. I've used this method before, but because of this web-page the class doesnt start at the beginning of the line, so I cant just set the entire line as the variable and $remove, because theres too many variables in the line.

Thanks

Joined: Apr 2004
Posts: 217
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Apr 2004
Posts: 217
Something that might help you (I DID NOT CREATE this identifier, I do not claim I did. I picked it up myself from another script a long time ago.)

alias nohtml { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ) | return %x }

This command will remove the HTML tags.
So therefore turning "<div class="something">Hello There</div>"
info "Hello There".

$nohtml(<html><span>Text Here.</span></html>) = Text Here. =p

S
Stefan_Leroux
Stefan_Leroux
S
Well, not quite what I need at this point. That will still leave me with lots of bunk and not just the litlle bit i need.

I wish the site was a cleaner layout, but well, its not mines frown.

But HTML remover is perfect for other stuff, so cheers anyway mate.

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
You usually need to use tokens to handle text from sites. Use $gettok to get what you're trying to out of a line of text.

Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
You should be able to use regex to use to get any info you need.

Code:
var %in = <div class="divclass">info goes in here</div><div class="divclass2">more info goes in here</div>
noop $regex(div,%in,/<div class="divclass">(.*?)</div>/i)
var %var1 = $regml(div,1)


(regex untested)

-genius_at_work


Link Copied to Clipboard