Solved

Get part text from html source

Posted on 2008-10-01
7
179 Views
Last Modified: 2012-05-05
the source is

<strong>No:</strong> <ins>59520</ins>(f)<br /> or
<strong>No:</strong> <ins>59520</ins>(m)<br />

how to get "m"   or  "f" and 59520 is not a constant it is always number but not constant


and another one


<strong>@O:>@:</strong> <ins class="female">BeBcHo0o0o__</ins><em>

i need the text betwen "ins"  tag  this text "BeBcHo0o0o__"

0
Comment
Question by:dupetata
  • 4
  • 3
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 22613349
for( '<strong>No:</strong> <ins>59520</ins>(f)<br />', '<strong>No:</strong> <ins>59520</ins>(m)<br />' ){
     print m(</ins>\W*(\w)),"\n";
}

for( '<strong>@O:>@:</strong> <ins class="female">BeBcHo0o0o__</ins><em>' ){
    print m(<ins\b[^>]*>(\w+)),"\n";
}
0
 

Author Comment

by:dupetata
ID: 22613454
ozo the number 59520 isnot a constant is always changing
0
 

Author Comment

by:dupetata
ID: 22613469
and BeBcHo0o0o__ too
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 84

Expert Comment

by:ozo
ID: 22613516
that's why the m(</ins>\W*(\w)) and m(<ins\b[^>]*>(\w+) try to match the ins, not the 59520  or BeBcHo0o0o__
if the ins also changes, then I'm not sure how you want to determine which part to get.
0
 

Author Comment

by:dupetata
ID: 22613714
ok u didnt get me i have for loop


for my $ids ($start..$end) {
        my $res=$www->get("http://site.com/u:$ids");
        unless($res->is_success) {
                warn "Could not get id $ids: " . $res->code . "\n";
                next;
        }
i need to do it that way

if($res->content =~ /<strong>No:</strong> <ins>some number</ins>(*)<br />/)

and get the value of *
then in the same loop

($value) = $res->content =~ /<ins class="female">***</ins><em>/

and get the value of ***
0
 
LVL 84

Expert Comment

by:ozo
ID: 22613899
if( $res->content =~ /<strong>No:<\/strong> <ins>\d+\/ins>(.*?)<br \/>/ ){
    print $1;
}
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 22613956
if( $res->content =~ /<strong>No:<\/strong> <ins>\d+<\/ins>(.*?)<br \/>/ ){
    print $1;
}

($value) = $res->content =~ /<ins class="female">(.*?)<\/ins><em>/;
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question