Wednesday, 8 October 2014

Test 17: Print ALT text and URL of all images in a page

Test:
Get all images of a page and print ALT text and URL

Learning: 
$m->images() is used for images



Solution:

use WWW::Mechanize;

my $m = WWW::Mechanize->new();
$m->get("http://vienna.yapceurope.org/ye2007/search");
@arr=$m->images();
$count=1;
foreach(@arr)
{
print "Image $count \n";
$tmp=$_->alt;
print "ALT is $tmp\n";
$tmp=$_->url;
print "URL is $tmp\n\n";
$count++;
}



output snapshot:

No comments:

Post a Comment