Here's a solution using LWP to spider for number of pictures, description, author and title before they add their site:
In add.cgi replace: if (keys %in != 0) {
&process_form;
}
With: if (keys %in != 0) {
if ($in{'spider'}){
&spider_it;
}
else {
&process_form;
}
}
Replace: else {
&site_html_add_form ();
}
With: else {
&spider_site;
}
At the bottom of add.cgi add: sub spider_it {
use LWP::Simple;
my $url = get "$in{'url'}";
@content=split(/\n/,$url);
$count = 0;
foreach $line (@content) {
chomp($line);
($title = $1) if ($line =~ m|<TITLE>([^"]+)</TITLE>|i);
($description = $1) if ($line =~ m|<meta name="Description" content="([^"]+)">|i);
($name = $1) if ($line =~ m|<meta name="Author" content="([^"]+)">|i);
$count++ if ($line =~ m|<img src|i);
&site_html_add_form ();
}
sub spider_site {
print qq|
<form action="add.cgi" METHOD=POST>
<input type="text" name="url"><input type=submit value="Spider" name="spider">
</form>
|;
}
In site_html_templates.pl replace sub site html add form with: sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;
my $category = shift;
$category ?
($category = qq~$category <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
print &load_template ('add.html', {
Category => $category,
description => $description,
title => $title,
name => $name,
count => $count,
%globals
});
}
Then in add.html add a hidden field with a value <%count%> (gives the number of pictures on the page spidered) and use value = <%title%> etc.. for the title, description and contact name fields if you want to use the stuff collected from the spidered page. Glenn
Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml