#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Pane; use WWW::Mechanize; use Web::Scraper; use Data::Dumper; use threads; my $mw = tkinit(); $mw->geometry('300x300+100+100'); my $sp = $mw->Scrolled('Pane',-scrollbars=>'osoe',sticky=>'nwse')->pack(-expand=>1,-fill=>'both'); $sp->Label(-text=>"Give Keyword file")->pack(); my $entry1 = $sp->Entry()->pack(); my $showbutton = $mw->Button(-text=>'Submit', -command =>\&button_callback)->pack(); my $bimage = scraper { process "img" , "url[]" => '@src'; }; sub button_callback { my $filename = $entry1->get(); open FH, $filename or die $!; while (my $tmpline = ) { my $thr1 = threads->new(\&threadsub($tmpline)); if(threads->list(threads::running)) { print "Waiting for all threads to complete running"; } $thr1->join(); } sub threadsub { my $line =$_; chomp($line); my @temp = split(/ /,$line); my $query = join('+',@temp); our $ibing = "http://www.bing.com/images/search?count=10&q=".$query; my $mech = WWW::Mechanize->new; $mech->get($ibing); #print Dumper $mech->content; my $res = $bimage->scrape($mech->content,$mech->uri); print Dumper $res; } close (FH); } MainLoop();