szabgab has asked for the wisdom of the Perl Monks concerning the following question:
If I change the $source to be http://code.foo.no/feed then I keep getting "1: Bad Behavior".use strict; use warnings; use URI::Fetch; use LWP::UserAgent; my $source = 'http://thorsen.pm/atom'; my $res2 = URI::Fetch->fetch($source); print '2: ' . URI::Fetch->errstr if not $res2; my $ua = LWP::UserAgent->new; $ua->env_proxy; # force allowing of proxies my $res1 = URI::Fetch->fetch($source, UserAgent => $ua); print '1: ' . URI::Fetch->errstr if not $res1;
Very strange. Other URLs I tried work well.
And just to explain why is this important, I am using XML::Feed to fetch and parse RSS and Atom feeds, and XML::Feed uses the code as it is written in the problematic case. So currently these two feeds keep giving me error.
Apparently those two servers refuse to serve to the well known Perl user agent. Probably in an attempt to fend off certain bots.
So I have to change the UserAgent in XML::Feed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: URI::Fetch and LWP::UserAgent strangeness
by Gryllida (Acolyte) on Jun 03, 2013 at 02:14 UTC | |
by jdporter (Paladin) on Jun 03, 2013 at 04:04 UTC |