2012-06-25 3 views
0

검색을 시도했지만 가까운 답을 찾을 수 없습니다.Perl 모듈 (WWW :: Mechanize) 페이지에서 이미지 선택

내가 가지고있는 것은이 (링크 및 URL이 변경되지만 개념을 정확히 동일합니다)

#!/usr/bin/perl 
#Some of the modules are going to be unused for now 
use Win32::OLE; 
use Win32::Ole::Variant; 
use LWP::Simple; 
use DBI; 
use DBD::mysql; 
use WWW::Mechanize qw(); 

$url = 'http://example.com'; 
$mechanize = WWW::Mechanize->new(autocheck => 1); #BTW what's autocheck=>1 for? 
$mechanize->get($url); 
$content = $mechanize->content(); 

print $content; #Shows the HTML (OK) 

$mechanize->form_name('search'); 
$mechanize->field('level', '100'); 
$response = $mechanize->submit(); 

print $response->content(); #Shows the html of the submitted page (OK); 

지금이 새로운 형태의 임의의 이미지가 그 .JPG도 다른되지 않은 이미지 포맷을 생성 . 내가하고 싶은 일은 그 이미지를 내 폴더에 저장하는 것뿐입니다. 이미지 태그는 폴더에 <img src="someImage.php"> and I would like to save it as someImage.jpg`입니다.

답변

2

당신이하지 않은 documentation of the software you are using을 읽는 것이 도움이됩니다. 이미지 방법이 필요합니다.

use strictures; 
use WWW::Mechanize qw(); 
my $m = WWW::Mechanize->new; # autocheck is default since v1.50 (year 2008) 
$m->get('file:///tmp/so11184595.html'); 
for my $i ($m->images) { 
    $m->mirror($i->url_abs, 'some/someImage.jpg') 
     if 'someImage.php' eq $i->url; 
} 
+0

내가 그렇게하고 "패키지를 통해"HTTP : 헤더를 "이미지"개체 방법을 찾을 수 없습니다 "라는 메시지를 얻을" – Grigor

+0

내가 쓴 프로그램은 작동합니다. 당신이 그것을 변경했습니다 : 당신은'get'에 의해 반환 된 응답 객체에 대해'images' 메소드를 호출하고 있습니다. 이것은 잘못된 것입니다. – daxim

+0

이미지의 목록을 어떻게 볼 수 있습니까? 프로그램은 작성한대로 작동하지만 저장 한 이미지를 볼 수 없습니다. – Grigor

관련 문제