这个用的是POE里面的一个模块
#创建语句
        POE::Component::Client::HTTP->spawn(
            Alias           => $self->{http_alias},
            Timeout         => 60,
            FollowRedirects => 2,
            Agent           => 'Mozilla/5.0 (X11; U; Linux i686; en-US; ' .
                               'rv:1.1) Gecko/20020913 Debian/1.1-1',
        );
#发送请求
    $kernel->post(
        $self->{http_alias} => request => _response =>
        $req,                                                #传递的参数
        $uniq_feed->hashcode,                      #传递的参数
    );
#然后又一个 sub _response负责接收处理

my $res = $req->[0];
if ( $res->is_success ) {
   my $content = $res->content;
}
上面这两句就是在_response函数里面的

2009/12/14 msmouse <[email protected]>

> 楼主是用什么方法把request发出去的? 仿佛没贴那句
>
>
>
> ----------------------------------
> [email protected]
> [email protected]
>
>
> 2009/12/14 周鹏远 <[email protected]>
>
> 这句话好像是LWP::UserAgent模块里面的HTTP::Request里面并没有这个方法
>>
>> 2009/12/14 msmouse <[email protected]>
>>
>>  $ua->proxy(https=>$self->{proxy});
>>>
>>> ----------------------------------
>>> [email protected]
>>> [email protected]
>>>
>>>
>>> 2009/12/14 小飞侠 <[email protected]>
>>>
>>> 既存的程序里获取网页内容的语句摘要如下
>>>> use HTTP::Request::Common qw(GET);
>>>> ......
>>>>
>>>>  my $req = GET $uniq_feed->url;
>>>>
>>>> ......
>>>>
>>>>  $req->headers->authorization_basic(
>>>>    $username,
>>>>    $password
>>>> )
>>>>
>>>> .......
>>>>
>>>> my $res = $req->[0];
>>>> if ( $res->is_success ) {
>>>>    my $content = $res->content;
>>>> }
>>>> 目前需要在既存程序的基础上,对应需要使用代理服务器访问网络的情况。
>>>> 请高手指教
>>>>
>>>> --
>>>>
>>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
>>>> 要取消订阅此网上论坛,请发送电子邮件至 
>>>> [email protected]<perlchina%[email protected]>
>>>> 。
>>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>>>>
>>>>
>>>>
>>>  --
>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
>>> 要取消订阅此网上论坛,请发送电子邮件至 
>>> [email protected]<perlchina%[email protected]>
>>> 。
>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>>>
>>
>>  --
>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
>> 要取消订阅此网上论坛,请发送电子邮件至 
>> [email protected]<perlchina%[email protected]>
>> 。
>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>>
>
>  --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 
> [email protected]<perlchina%[email protected]>
> 。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>

--

您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。


回复