Simple Perl Help

Discussion in 'Programming' started by MelogKnaj, Dec 5, 2008.

  1. #1
    I want a perl script to search a web page for a link containing certain anchor text, follow that link and then return the URL it goes to. I have looked online and really have no idea where to start. Any help you guys could give would be great.
     
    MelogKnaj, Dec 5, 2008 IP
  2. happpy

    happpy Well-Known Member

    Messages:
    926
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    120
    #2
    happpy, Dec 5, 2008 IP
  3. bille

    bille Peon

    Messages:
    269
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This should get you started...

    #!/usr/bin/perl
    use LWP::Simple;
    my $url = "http://somewebsite.com/";
    my $content = get $url or die "couldn't get content: $!\n";
    print "$content\n";
    Code (markup):
    Then read up on how to parse html in perl.

    This article is older, but still applicable:

    http://www.foo.be/docs/tpj/issues/vol5_1/tpj0501-0003.html
     
    bille, Dec 5, 2008 IP
  4. MelogKnaj

    MelogKnaj Active Member

    Messages:
    233
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #4
    If you had read my post you would realize I am not looking for a perl crawler. Also plugging your own custom search in an effort to make money is extremely annoying.

    Thanks bille, do I really need to print the content to search it? Should I just be able to search within the page I'm on?
     
    MelogKnaj, Dec 6, 2008 IP