Open URL from email message

Discussion in 'Perl Misc' started by Lev Altshuler, Jul 5, 2003.

  1. Hi,

    When reading from email message using Net::pOP3 (or other means),
    I need my perl program to open URLs incuded into the message. In other
    words, I need the program to click links in the message.
    So far I have not found the solution for that either in Net::pOP3 or
    anywhere else.
    Does anyone have an idea how to do that?

    Thanks, Lev
     
    Lev Altshuler, Jul 5, 2003
    #1
    1. Advertising

  2. Internet Explorer can be launched with the following system call:
    system("start $url");
    where $url is a variable where we stored URL read by Net::pOP3.
    But the task is to emulate a click on the link from email message. Launching
    the browser is not
    an issue here. I am not certain that launching the browser as I described
    above will emulate
    a click on the link from email message.

    "Mina Naguib" <> wrote in message
    news:XLoNa.63680$...
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Lev Altshuler wrote:
    > > Hi,
    > >
    > > When reading from email message using Net::pOP3 (or other means),
    > > I need my perl program to open URLs incuded into the message. In other
    > > words, I need the program to click links in the message.
    > > So far I have not found the solution for that either in Net::pOP3 or
    > > anywhere else.
    > > Does anyone have an idea how to do that?
    > >
    > > Thanks, Lev

    >
    > Net::pOP3 handles, obviously, the POP3 protocol. In other words,

    "download this chunk of text, it
    > should resemble something parse-able by an email client as an email

    message".
    >
    > That's all there is to it, a chunk of text in an agreed-on format.
    >
    > Anything beyond that, you have to do yourself. If you expect that chunk

    of message to have URLs
    > that you are interested in, then you need to extract these URLs. For

    simple text emails, you can
    > probably get away with using a simple regular expression to collect the

    URLs. For HTML-encoded
    > emails, you can probably use HTML::TokeParser to cleanly extract links.
    >
    > Once you have the URLs (still, chunks of text) in a variable somewhere,

    you want to simulate a
    > "click". In other words, you want to launch a web browser that visits

    these URLs.
    >
    > Fortunately, perl comes with what you need. Look into any of the LWP*

    family of modules. For simple
    > GET requests with no further interaction, LWP::Simple might be what you're

    looking for.
    >
    > Best of luck.
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v1.2.1 (GNU/Linux)
    > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
    >
    > iD8DBQE/Bhh3eS99pGMif6wRAvX6AJ9SgfwHu7BoyeKvW2QXrYkr2Us7oACglhRw
    > CZqJOuOT4wA+yt2t866cBic=
    > =Vz0g
    > -----END PGP SIGNATURE-----
    >
     
    Lev Altshuler, Jul 5, 2003
    #2
    1. Advertising

  3. Lev Altshuler <> wrote:

    [ dejeopardized, follow-ups set to clpmisc ]

    > "Mina Naguib" <> wrote:
    >> Lev Altshuler wrote:
    >>> I need my perl program to open URLs incuded into the message. In other
    >>> words, I need the program to click links in the message.

    >>
    >> LWP::Simple might be what you're looking for.
    >>

    > Internet Explorer can be launched with the following system call:
    > system("start $url");
    > where $url is a variable where we stored URL read by Net::pOP3.
    > But the task is to emulate a click on the link from email message.

    ^^^^^^^^

    Isn't it a little summery for homework?

    > Launching the browser is not an issue here. I am not certain that
    > launching the browser as I described above will emulate a click on
    > the link from email message.


    You can emulate a *click* on the link using return().

    sub click {
    my $thing = shift;
    return;
    }

    This is approximately what mutt does when you click on anything,
    and I think it's correct behavior.

    HTH
    --
    Steve
     
    Steve Grazzini, Jul 5, 2003
    #3
  4. Thank you, Steve.
    Could you please explain how click() function calls $url ?
    Say, $url is a variable where URL is stored.


    "Steve Grazzini" <> wrote in message
    news:usqNa.18158$...
    > Lev Altshuler <> wrote:
    >
    > [ dejeopardized, follow-ups set to clpmisc ]
    >
    > > "Mina Naguib" <> wrote:
    > >> Lev Altshuler wrote:
    > >>> I need my perl program to open URLs incuded into the message. In other
    > >>> words, I need the program to click links in the message.
    > >>
    > >> LWP::Simple might be what you're looking for.
    > >>

    > > Internet Explorer can be launched with the following system call:
    > > system("start $url");
    > > where $url is a variable where we stored URL read by Net::pOP3.
    > > But the task is to emulate a click on the link from email message.

    > ^^^^^^^^
    >
    > Isn't it a little summery for homework?
    >
    > > Launching the browser is not an issue here. I am not certain that
    > > launching the browser as I described above will emulate a click on
    > > the link from email message.

    >
    > You can emulate a *click* on the link using return().
    >
    > sub click {
    > my $thing = shift;
    > return;
    > }
    >
    > This is approximately what mutt does when you click on anything,
    > and I think it's correct behavior.
    >
    > HTH
    > --
    > Steve
     
    Lev Altshuler, Jul 5, 2003
    #4
  5. Beable van Polasm <> writes:
    > As for "emulating a click", what other actions do you think that
    > clicking on a link would have than to get a web browser to display
    > the page linked to?


    The answer, if it's HTML mail, and javascript is enabled, is "darn
    near anything". If the machine in question runs Windows, even more
    so.

    -=Eric
    --
    Come to think of it, there are already a million monkeys on a million
    typewriters, and Usenet is NOTHING like Shakespeare.
    -- Blair Houghton.
     
    Eric Schwartz, Jul 7, 2003
    #5
    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. Lev Altshuler

    Open URL from email message

    Lev Altshuler, Jul 5, 2003, in forum: Perl
    Replies:
    4
    Views:
    5,245
    Eric Schwartz
    Jul 7, 2003
  2. Chuck Amadi
    Replies:
    2
    Views:
    420
    chuck amadi
    Jun 6, 2004
  3. David Stockwell
    Replies:
    1
    Views:
    652
    David Bolen
    Jun 17, 2004
  4. Rogério Brito
    Replies:
    1
    Views:
    704
    Sean DiZazzo
    Sep 9, 2009
  5. Chris Rebert
    Replies:
    0
    Views:
    176
    Chris Rebert
    Dec 28, 2012
Loading...

Share This Page