mIRC Home    About    Download    Register    News    Help

Print Thread
#174987 15/04/07 01:59 PM
Joined: Jun 2003
Posts: 17
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Jun 2003
Posts: 17
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


Swift as the Wind
Silent as a Forest
Fierce as Fire
Immovable as a Mountain
Joined: Apr 2004
Posts: 218
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Apr 2004
Posts: 218
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


Live to Dream & Dream for Life
Joined: Jun 2003
Posts: 17
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Jun 2003
Posts: 17
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.


Swift as the Wind
Silent as a Forest
Fierce as Fire
Immovable as a Mountain
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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