mIRC Home    About    Download    Register    News    Help

Print Thread
Wildcards in variables? #174987 15/04/07 01:59 PM
Joined: Jun 2003
Posts: 17
S
Stefan_Leroux Offline OP
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
Re: Wildcards in variables? [Re: Stefan_Leroux] #174989 15/04/07 02:15 PM
Joined: Apr 2004
Posts: 218
P
PhantasyX Offline
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
Re: Wildcards in variables? [Re: PhantasyX] #175002 15/04/07 06:23 PM
Joined: Jun 2003
Posts: 17
S
Stefan_Leroux Offline OP
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
Re: Wildcards in variables? [Re: Stefan_Leroux] #175006 15/04/07 09:24 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
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
Re: Wildcards in variables? [Re: Stefan_Leroux] #175028 16/04/07 04:55 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
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