简单的 perl 代码是:
use WWW::Scripter;
...
my $w = WWW::Scripter->new('agent' => 'myAgent');
$w->use_plugin('JavaScript');
...
$w->get($url);
### WWW::Mechanize automatic cookies = good for now
$w->add_header(Referer => $url);
$url = $w->document->getElementsByTagName('a')->[0]->href;
$w->get($url);
...
### WWW::Mechanize automatic cookies = NOT good for now
### ! need to clear cookie jar here !
...
$w->add_header(Referer => $url);
$url = $w->document->getElementsByTagName('a')->[0]->href;
$w->get($url);
WWW::Mechanize
的一个很好的功能是自动Cookie ,这在某些方面很好,但有时需要清除Cookie。怎么样?