0

SOを検索しようとしましたが、近い答えが見つかりませんでした。

私が持っているのはこれです(リンクと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` です。

4

1 に答える 1

2

使用していないソフトウェアのドキュメントを読むと役立ちます。画像メソッドが必要です。

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;
}
于 2012-06-25T08:37:05.323 に答える