简单的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。如何?