go to a link, save the page and email it out?

Discussion in 'Perl Misc' started by dale, Dec 14, 2004.

  1. dale

    dale Guest

    Hi,

    Does anyone know if there is a perl module to do the above?
    Thanks. -Dale
     
    dale, Dec 14, 2004
    #1
    1. Advertising

  2. dale

    Matija Papec Guest

    X-Ftn-To: dale

    "dale" <> wrote:
    >Does anyone know if there is a perl module to do the above?


    HTML::Mail works nicely.



    --
    Matija
     
    Matija Papec, Dec 14, 2004
    #2
    1. Advertising

  3. On 2004-12-14, dale scribbled these
    curious markings:
    > Does anyone know if there is a perl module to do the above?
    > Thanks. -Dale


    package MailPage;
    use strict;
    use warnings FATAL => 'all';

    use LWP::Simple;
    use MIME::Lite;
    use Carp;
    use base qw/Exporter/;
    use vars qw/@EXPORT_OK/;
    @EXPORT_OK = qw/mail_page/;

    sub mail_page
    {
    croak "mail_page needs four arguments!" unless @_ == 4;
    my ($page, $from, $to, $subject) = @_;
    my $content = get($page);
    croak "Couldn't fetch $page!" unless defined $content;
    my $msg = MIME::Lite->new
    (
    From => $from,
    To => $to,
    Subject => $subject,
    Data => $content,
    );
    $msg->send() or carp "Uh oh, problems sending mail!"
    }
    1;
    __END__

    #!/usr/bin/perl
    use strict;
    use warnings FATAL => 'all';

    use MailPage qw/mail_page/;
    mail_page(q#http://www.google.com#, q##,
    q##, q#A Test#);

    __END__

    WFM. Took about 5 minutes (mostly because I'm not too familiar with most
    of the modules used).

    /me braces for the inevitable torrent of code review he's going to
    receive...

    Best Regards,
    Christopher Nehren
    --
    I abhor a system designed for the "user", if that word is a coded
    pejorative meaning "stupid and unsophisticated". -- Ken Thompson
    If you ask the wrong questions, you get answers like "42" and "God".
    Unix is user friendly. However, it isn't idiot friendly.
     
    Christopher Nehren, Dec 14, 2004
    #3
  4. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2004-12-14, Christopher Nehren scribbled these
    curious markings:
    > $msg->send() or carp "Uh oh, problems sending mail!"

    ^^^^

    Self-review: that should probably be croak.

    Best Regards,
    Christopher Nehren
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.6 (FreeBSD)

    iD8DBQFBvy8+k/lo7zvzJioRAq4RAKCZDdQsKGN3Qwt526VnfKUfaXss+QCgluo4
    Uzpdd3l6dWZ7lutd+tTY288=
    =JDeH
    -----END PGP SIGNATURE-----

    --
    I abhor a system designed for the "user", if that word is a coded
    pejorative meaning "stupid and unsophisticated". -- Ken Thompson
    If you ask the wrong questions, you get answers like "42" and "God".
    Unix is user friendly. However, it isn't idiot friendly.
     
    Christopher Nehren, Dec 14, 2004
    #4
  5. dale

    dale Guest

    HTML::Mail works for some web sites. But some web sites have
    protections for reading some files, which is expected. THe results are:

    C:\Perl\scripts>mailp.pl
    Error while making request [ GET
    http://www.macom.com/Images/darkblue_bgcolor.gi
    f]
    404 Object Not Found at C:/Perl/lib/HTML/Mail.pm line 167.

    C:\Perl\scripts>

    However, if I use IE to open www.macom.com, I can save the page with
    all images. Any suggestions?

    Thanks a lot. -Dale
     
    dale, Dec 15, 2004
    #5
  6. dale

    dale Guest

    HTML::Mail works for some web sites. But some web sites have
    protections for reading some files, which is expected. THe results are:

    C:\Perl\scripts>mailp.pl
    Error while making request [ GET
    http://www.macom.com/Images/darkblue_bgcolor.gi
    f]
    404 Object Not Found at C:/Perl/lib/HTML/Mail.pm line 167.

    C:\Perl\scripts>

    However, if I use IE to open www.macom.com, I can save the page with
    all images. Any suggestions?

    Thanks a lot. -Dale
     
    dale, Dec 15, 2004
    #6
  7. dale

    dale Guest

    Tried the simple one.

    HTML::Mail works for some web sites. But some web sites have
    protections for reading some files, which is expected. THe results are:

    C:\Perl\scripts>mailp.pl
    Error while making request [ GET
    http://www.macom.com/Images/darkblue_bgcolor.gi
    f]
    404 Object Not Found at C:/Perl/lib/HTML/Mail.pm line 167.

    C:\Perl\scripts>

    However, if I use IE to open www.macom.com, I can save the page with
    all images. Any suggestions?

    Thanks a lot. -Dale
     
    dale, Dec 15, 2004
    #7
  8. dale

    dale Guest

    Thank you all. I tried HTML::Mail, it worked. It is simple.

    -Dale
     
    dale, Dec 15, 2004
    #8
  9. dale

    dale Guest

    Thank you all. I tried HTML:Mail and worked. It is simple.

    -Dale
     
    dale, Dec 15, 2004
    #9
  10. dale

    Guest

    HTML::Mail works for some web sites. But some web sites have
    protections for reading some files, which is expected. THe results are:

    C:\Perl\scripts>mailp.pl
    Error while making request [ GET
    http://www.macom.com/Images/darkblue_bgcolor.gi
    f]
    404 Object Not Found at C:/Perl/lib/HTML/Mail.pm line 167.

    C:\Perl\scripts>

    -----Mail.pm
    164 my $response = $self->{'_ua'}->get($uri);
    165
    166 if (!$response->is_success) {
    167 die "Error while making request [ GET ", $response->request->uri,
    "]\n", $response->status_line;
    168 }

    However, if I use IE to open www.macom.com, I can save the page with
    all images. Any suggestions?

    Thanks a lot. -Dale
     
    , Dec 15, 2004
    #10
  11. dale

    Matija Papec Guest

    X-Ftn-To: dale

    "dale" <> wrote:
    >HTML::Mail works for some web sites. But some web sites have
    >protections for reading some files, which is expected. THe results are:


    I'm not sure if protection is the case but you can convince other side that
    you're using fancy browser,
    $html_mail->lwp_ua->agent("Mozilla/5.0");

    >C:\Perl\scripts>mailp.pl
    >Error while making request [ GET
    >http://www.macom.com/Images/darkblue_bgcolor.gi
    >f]
    >404 Object Not Found at C:/Perl/lib/HTML/Mail.pm line 167.
    >
    >C:\Perl\scripts>
    >
    >However, if I use IE to open www.macom.com, I can save the page with
    >all images. Any suggestions?


    Probably there is no image and IE doesn't bother about that.



    --
    Matija
     
    Matija Papec, Dec 17, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    901
    Kevin Spencer
    May 17, 2005
  2. Flatch U. Lance
    Replies:
    7
    Views:
    1,058
    Flatch U. Lance
    Mar 4, 2006
  3. subhadip
    Replies:
    0
    Views:
    661
    subhadip
    Mar 28, 2007
  4. dale
    Replies:
    1
    Views:
    118
    Anno Siegel
    Dec 16, 2004
  5. Replies:
    2
    Views:
    122
Loading...

Share This Page