Perl uses parameters to pass URL for HTML Parsing

Source: Internet
Author: User

#! C:/perl64/bin/perl
Require lwp: useragent;
 
My $ UA = lwp: useragent-> new;
$ UA-> timeout (10 );
$ UA-> env_proxy;
 
My ($ url_new, $ url_old) = @ argv;
My $ response = $ UA-> get ($ url_new );
Die $ response-> status_line unless ($ response-> is_success );
# Print $ response-> decoded_content; # Or whatever whole file
My @ contents_new = Split (/<\/tr>/, $ response-> decoded_content );
My $ eachline = UNDEF;
# $ Response-> decoded_content just one line
# So if dealing with the line, us split

Foreach $ eachline (@ contents_new ){
Chomp $ eachline;

Next unless ($ eachline = ~ /<Tr> <TD align = "Left">/); # Sometime be not so strict
 
If ($ eachline = ~ /Html "> (.*?) <.*? "> \ S? ([0-9] + \. [0-9]) <\/TD>
.*? > ([0-9] + \. [0-9] | n \/A) + <
.*? > ([0-9] + \. [0-9] | n \/A) + <
.*? Html "> (.*?) <
.*? "> (.*?) <\/TD>/X)
{
Printf ("%-145s \ t: %-3.1f \ t %-3.1f \ t %-3.1f \ n", $1, $2, $5, $6 );
}

}
Print "********************************* \ n ";

= Comment
# My @ contents = $ response-> decoded_content;
# Foreach my $ content (@ contents ){
# Print $ content;
#}
$ Response = $ UA-> get ($ url_old );
Die $ response-> status_line unless ($ response-> is_success );
Print $ response-> decoded_content; # Or whatever whole file
# My @ contents_new = $ response-> decoded_content;
My @ contents_old = $ response-> decoded_content;
My $ eachline1 = UNDEF;
Foreach $ eachline1 (@ contents_old ){
Print $ eachline1 ."###";
}
 

# Use lwp: useragent;
# $ Browser = lwp: useragent-> new;
# $ Target_url = "http://search.cpan.org ";
# $ Response = $ browser-> post ($ target_url );
# $ Htmlcontent = $ response-> content;
# Print $ htmlcontent. "\ n ";

= Cut

The email sending function is displayed in HTML.

Use Net: SMTP;


My $ SMTP = net: SMTP-> New ($ email_server );
$ SMTP-> mail ($ email_sender );
My @ receivers = Split (";", $ email_receivers );


$ SMTP-> recipient (@ receivers );
$ SMTP-> data ();
$ SMTP-> datasend ("mime-version: 1.0 \ n ");
$ SMTP-> datasend ("Content-Type: text/html; charset = US-ASCII \ n ");
$ SMTP-> datasend ("to: $ email_receivers \ n ");
$ SMTP-> datasend ("Subject: STF change \ n ");
$ SMTP-> datasend ("$ result_content \ n ");
$ SMTP-> quit;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.