Menu
I’m looking for a way to find <input type=”hidden” name=”ADDITEM” value=”____”> in a web site that contains over 1000 pages. Need it to sort our data base out. Kinda looking for scripts, programs, or a software
?
Felgal- it does not work when you trying to find HTML code thanks anyway[/QUOTE]
I am running XP pro sp2, I'll try describe what i need to do the best i can, we have a web (Yup, it sounds like Perl would do the trick. But you still haven't answered my questions above.www.poolcenter.com ) it has about 1,000 pages it all in HTML format, we are also using a database dydacom's MOM (mail order manger) with sitelink. we sell like over 2,500 products on our website and we over 5,000 in MOM. i am trying to figure outa way list all the products on our site and compare it to the ones in MOM.[/QUOTE]
#!c:perlbinperl.exe
use strict;
use HTML::TreeBuilder;
use LWP::Simple;
my @page = qw (http://www.poolcenter.com/cleaners_pol280_poolstor.htm);
foreach (@page) {
my $item = HTML::TreeBuilder->new_from_content (get $_)->look_down ('name', 'ADDITEM')->attr('value');
print "$_,$itemn";
};
But without a way of knowing what all of the files are called you are kind of dead in the water - unless you can run that thing in the same file system as your site.foreach (@page) {
my $root = HTML::TreeBuilder->new_from_file($_)
my @additems = $root->look_down ('name', 'ADDITEM');
foreach (@additem) {
print $_->attr ('value'), "n";
};
$root->delete() ;
};
If you are parsing more than one file you need to delete the tree after each one. #!c:perlbinperl.exe
use strict;
use File::Find;
use HTML::TreeBuilder;
find &callback, 'C:Documents and SettingsBriscoeMy DocumentsMy Web SitesSEARCHABLE';
sub callback {
if (/.htm/) {
my $root = HTML::TreeBuilder->new_from_file ( $_);
my @additems = $root->look_down ('name', 'ADDITEM');
foreach (@additems) {
print $_->attr ('value'), "n";
};
$root->delete();
};
};
#!c:perlbinperl.exe
{
package MyParser;
use base 'HTML::Parser';
<i> </i>sub start {
<i> </i> my($self, $tagname, $attr, $attrseq, $origtext) = @_;
<i> </i> if ($tagname eq 'input' && $$attr{name} && $$attr{name} eq 'ADDITEM') {
<i> </i> print "$$attr{value}n";
<i> </i> }
<i> </i>}
}
use strict;
use File::Find;
my $p = MyParser->new;
find &callback, 'C:Documents and SettingsBriscoeMy DocumentsMy Web SitesSEARCHABLE';
sub callback {
$p->parse_file ($_) if (/.htm/);
}
And this thread should have been moved to the Perl forum long ago.0.1.9 — BETA 6.1