K Gupta A wrote:
>
> I used
> Win32::OLE module
> as it opens up a new instance of internet explorer with my preferred webpage.
>
> now, i dont need to store all the html. i just need to store the html from
> $guts =~ /startpathwayimage(.*)endpathwayimage/;
>
> and then further process this into a file. so now i changed my code to:
>
> *********
> #!/usr/bin/perl
> use strict;
> use warnings;
> use LWP::Simple; # see search.cpan.org for more info
> my $guts = get('http://www.biocarta.com/pathfiles/h_il10Pathway.asp');
> $guts =~ tr/A-Z/a-z/;
> $guts =~ s/\"/'/g;
> $guts =~ s/\n//g;
> $guts =~ s/\s+//g;
> my @links = $guts =~ /startpathwayimage(.*)endpathwayimage/;
> open(STORE, ">output.txt") || die "Opening output.txt: $!";
> print STORE @links;
> close (STORE);
> ***********
> This output.txt has all the desired links that i need to store. I need to
> parse this output.txt to yield me all links sequence like this:
> http://link1.html
> http://link2.html
> http://link3.html
>
> there are around 15 links in javapop-ups!

Hi.

I am posting this code without comment, as explaining it all would take a
very long time and all of the documentation is available via perldoc.

HTH,

Rob


use strict;
use warnings;

use LWP::Simple;
use HTML::TokeParser;

my $url = 'http://www.biocarta.com/pathfiles/h_il10Pathway.asp';

my $content = get($url);
my $parse = new HTML::TokeParser \$content;

while (my $info = $parse->get_tag('map')) {
  my ($tag, $attr) = @$info;
  last if $attr->{name} eq 'm_h_il10Pathway';
}

while (my $info = $parse->get_tag('area', '/map')) {
  my ($tag, $attr) = @$info;
  last if $tag eq '/map';
  my ($href) = $attr->{href} =~ /'(.+?)'/;
  print $href, "\n";
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to