develooper Front page | perl.libwww | Postings from February 2001

Re: help parsing HTML code

Thread Previous
From:
Josh
Date:
February 1, 2001 01:39
Subject:
Re: help parsing HTML code
Message ID:
3A792DEE.7060603@inceptor.com
Marcel Grunauer wrote:

> In message <F217Vux1Zcn8TtEvzox0000139d@hotmail.com>, "gil cohen" writes:
> 
> 
>> You don't any of that weird stuff. All you need is a simple regex. In that 
>> $res->is_sucess if, put something like:
>> $content =~ m/<input type=\"text\" size=\"10\" name=\"video_fec_errors_rx\" 
>> value=\"(.*?)\" READONLY>/;
>> $value = $1;
>> 
>> and now $value has what value is equal to.
> 
> 
> Until someone decides to rearrange the parameters or make them uppercase
> or forgo quotes or split them among several lines.
> 
> Better use one of the HTML parsing modules.
> 
> BTW, no need to escape the quotes in the regex. And what happens if
> there is no match? Then $1 has an undefined value.

Hmm...how about searching for all the <input> tags, and then parsing the 
name id tag (everything between name= and the \s), and stripping out " 
and ' where appropiate.

I was always told to code one step at a time. Sure it takes longer code, 
but it will get you everything. Also you can check the id tag for other 
values.

Josh

-- 
Josh Barker, Web Researcher (joshb@inceptor.com) This mail may contain 
links to content of a illegal, immoral or sexual nature. These are not 
affliated with Inceptor and are for purposes of illustration only.

Tel : + 44 20 7661 9508 	F: + 44 20 7240 8098 		
MSN: josh_barker@hotmail.com 	AOL: Joshua C Barker
Mail: Inceptor, 33 St James's Square, London SW1, UK


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About