I am not sure what you mean by 'bad links', whether you mean incorrect html or links with a 404 on the other side. if you are looking for 404's, you could try this.. it only checks the links directly off of the root page ($url)

#!/usr/bin/perl -w use LWP::Simple; use HTML::TokeParser; use strict; my $url="http://www.perlmonks.org"; my $content = get("$url"); my $parse = HTML::TokeParser->new(\$content); my $testlink; while (my $token = $parse->get_tag("a")) { # put the link and the text into variables my $link = $token->[1]{href} || "-"; my $text=$parse->get_trimmed_text("/a"); # if $link is fully qualified url if ($link=~ m/http\:\/\//i){ # use LWP to get the link $testlink=get("$link"); if ($testlink){ # parse the title returned from the testlink for 404 or # not found errs my $testparse=HTML::TokeParser->new(\$testlink); if ($testparse->get_tag("title")) { my $title = $testparse->get_trimmed_text; if (($title=~ m/not found/i) || ($title=~ m/404/)) { print "* $link ($text) is a bad link\n"; } else { print "$link ($text) seems to be a good link\n"; } } } } else { # guess at qualifiny url by adding $url to the front.. $testlink=get("$url/$link"); if ($testlink) { my $testparse=HTML::TokeParser->new(\$testlink); if ($testparse->get_tag("title")) { my $title = $testparse->get_trimmed_text; if (($title=~ m/not found/i) || ($title=~ m/404/)) { print "* $url/$link ($text) is a bad link\n"; } else { print "$url/$link ($text) seems to be a good link\n"; } } } } } exit;

you may also want to check out How to ask questions the smart way..
-p

In reply to Re: Getting the contents of any 'url' by thatguy
in thread Getting the contents of any 'url' URGENT!!!!!!! by jenna2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.