Solved

Get part text from html source

Posted on 2008-10-01
7
161 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
Comment Utility
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
Comment Utility
ozo the number 59520 isnot a constant is always changing
0
 

Author Comment

by:dupetata
Comment Utility
and BeBcHo0o0o__ too
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 84

Expert Comment

by:ozo
Comment Utility
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
Comment Utility
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
Comment Utility
if( $res->content =~ /<strong>No:<\/strong> <ins>\d+\/ins>(.*?)<br \/>/ ){
    print $1;
}
0
 
LVL 84

Accepted Solution

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

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now