开发者

Using Cookie in Perl

I want to use Cookie in Perl but i have a problem . it's my code :

use LWP::UserAgent;
use开发者_开发百科 HTTP::Cookies;
$xpl = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5');
$req = HTTP::Request->new(GET => 'http://example.com') or die "\n\n Failed to Connect, Try again!\n"; 
my $cookie_jar = HTTP::Cookies->new(file => 'cookie.txt');
$xpl->cookie_jar($cookie_jar);
$res = $xpl->request($req);
print $xpl->request($req)->as_string;

and the content of cookie.txt is : 0fea8e55a89187d306d7db060b7b9ab7 . and when i runing this code i get this warning : cookie.txt does not seem to contain cookies at F:/Perl/lib/HTTP/Cookies.pm line 432, line 1.

what am i going to do ? Thanks in Advance .


The content of cookies.txt is supposed to be a file generated by HTTP::Cookies describing cookie names, values, domains, and expirations. The file you're giving it isn't in the format it uses, so it's not being loaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜