Open URL from email message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lev Altshuler

    Open URL from email message

    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

    #2
    Re: Open URL from email message

    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" <spam@thecouch. homeip.net> wrote in message
    news:XLoNa.6368 0$0B.1038336@wa gner.videotron. net...[color=blue]
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Lev Altshuler wrote:[color=green]
    > > 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[/color]
    >
    > Net::POP3 handles, obviously, the POP3 protocol. In other words,[/color]
    "download this chunk of text, it[color=blue]
    > should resemble something parse-able by an email client as an email[/color]
    message".[color=blue]
    >
    > 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[/color]
    of message to have URLs[color=blue]
    > that you are interested in, then you need to extract these URLs. For[/color]
    simple text emails, you can[color=blue]
    > probably get away with using a simple regular expression to collect the[/color]
    URLs. For HTML-encoded[color=blue]
    > emails, you can probably use HTML::TokeParse r to cleanly extract links.
    >
    > Once you have the URLs (still, chunks of text) in a variable somewhere,[/color]
    you want to simulate a[color=blue]
    > "click". In other words, you want to launch a web browser that visits[/color]
    these URLs.[color=blue]
    >
    > Fortunately, perl comes with what you need. Look into any of the LWP*[/color]
    family of modules. For simple[color=blue]
    > GET requests with no further interaction, LWP::Simple might be what you're[/color]
    looking for.[color=blue]
    >
    > Best of luck.
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v1.2.1 (GNU/Linux)
    > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
    >
    > iD8DBQE/Bhh3eS99pGMif6w RAvX6AJ9SgfwHu7 BoyeKvW2QXrYkr2 Us7oACglhRw
    > CZqJOuOT4wA+yt2 t866cBic=
    > =Vz0g
    > -----END PGP SIGNATURE-----
    >[/color]


    Comment

    • Steve Grazzini

      #3
      Re: Open URL from email message

      Lev Altshuler <levalt@rogers. com> wrote:

      [ dejeopardized, follow-ups set to clpmisc ]
      [color=blue]
      > "Mina Naguib" <spam@thecouch. homeip.net> wrote:[color=green]
      >> Lev Altshuler wrote:[color=darkred]
      >>> 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.[/color]
      >>
      >> LWP::Simple might be what you're looking for.
      >>[/color]
      > 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.[/color]
      ^^^^^^^^

      Isn't it a little summery for homework?
      [color=blue]
      > 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.[/color]

      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

      Comment

      • Beable van Polasm

        #4
        Re: Open URL from email message

        "Lev Altshuler" <levalt@rogers. com> writes:
        [color=blue]
        > 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.[/color]

        You know, top-posting and full-quoting like that will get a lot of
        people angry with you. You won't like it when a lot of people get
        angry with you. Read this page to find out how to do it so that
        everybody will accept your contributions:


        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?


        --
        No, YOU'RE A CRACKPOT, which is why you think I'm a crackpot...
        because all crackpots like you think everybody else is a moron
        not them. -- George Hammond

        Comment

        • Eric Schwartz

          #5
          Re: Open URL from email message

          Beable van Polasm <beable+unsenet @beable.com.inv alid> writes:[color=blue]
          > 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?[/color]

          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.

          Comment

          Working...