Ask a Question related to PERL Miscellaneous, Design and Development.
-
A. Sinan Unur #1
Re: URL checking
[email]mandy100@ihug.com.au[/email] (Mandy) wrote in news:6522b540.0306281641.4bbf5b23
@posting.google.com:
see [url]http://www.perldoc.com/perl5.8.0/lib/LWP.html#An-Example[/url]> Hi.
> I can't seem to find any examples that will help me learn how to check
> 2 things using a perl script.
>
> 1. Does a given page exist on a remote site
> e.g. If i want to check that my homepage's pictures.html page exists.
HTML::Parser is your friend.> 2. Does a page contain a url that I specify
> e.g. does my pictures.html page contain a link to my diary.html page
--
A. Sinan Unur
[email]asu1@c-o-r-n-e-l-l.edu[/email]
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
A. Sinan Unur Guest
-
checking for values
hi. i'd like to perform a check on some values. these values are being populated into a structure that i'm then returning to flash. here's how it's... -
Checking inequality
I have the following code in one of my trigger functions --------------------------------------------------------------- IF... -
checking duplicates
Hi all, i'm trying to figure out how I can check for duplicates entries in an array and remove the duplicate. Example: 23,23,39,40,44,44 should... -
Just checking out the new look...
....it's definitely different! Will take some getting used to. :-) Barb -
Checking for process(es)
Hello, Some of the programs i am currently writing (one depends on another) write their pids to file (create pid files). Now i want to check if... -
Tad McClellan #2
Re: URL checking
Mandy <mandy100@ihug.com.au> wrote:
> 1. Does a given page exist on a remote site
Try and "fetch" it, if you get a good-looking response, then
the resource exists.
^^^> 2. Does a page contain a url that I specify
^^^
> I know there must be examples out there but my choice of keywords
> hasn't been too productive yet.
Errr, OK.
perldoc -q fetch
How do I fetch an HTML file?
perldoc -q url
How do I extract URLs?
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
Mark Jason Dominus #3
Re: URL checking
In article <6522b540.0306281641.4bbf5b23@posting.google.com >,
Mandy <mandy100@ihug.com.au> wrote:I usually use the LWP::Simple module for that. First install the>Hi.
>I can't seem to find any examples that will help me learn how to check
>2 things using a perl script.
>
>1. Does a given page exist on a remote site
>e.g. If i want to check that my homepage's pictures.html page exists.
module by running the command:
perl -MCPAN -e 'install LWP::Simple'
Once you have LWP::Simple, you can use it to check for a page this
way:
use LWP::Simple;
if (head($url)) {
# it seems to exist
} else {
# not
}
Similarly, you can use LWP::Simple to fetch the page's content, and>2. Does a page contain a url that I specify
>e.g. does my pictures.html page contain a link to my diary.html page
then search through it looking for the link. Try
use LWP::Simple;
use HTML::LinkExtor; # "Link Extractor"
my $content = get($url);
if (defined $content) {
my $found = 0;
HTML::LinkExtor->new(sub { my $tag, %links = @_;
for (values %links) {
$found = 1 if $_ eq "diary.html";
}
}, $url)
->parse($content);
if ($found) {
# found it
} else {
# didn't find it
}
}
Good luck.
Mark Jason Dominus Guest



Reply With Quote

