Python equivalent of LWP and HTTP in Perl
Erik Johnson
spam at nospam.org
Thu Oct 28 19:12:20 EDT 2004
"Irmen de Jong" wrote
> > my($ua) = LWP::UserAgent->new;
> > my $req = GET "$uri";
> > $req->header(Referer => "$referer");
> > $ua->proxy('http', 'http://localhost:8080/'); # Proxomitron
> > $response = $ua->request($req);
> > $respcode = $response->code;
>
>
> import urllib
> proxies = {'http': 'http://localhost:8080/'}
> response = urllib.urlopen("some_url", proxies=proxies).read()
... which is short and clean, but ignores the Referer header.
I have worked with httplib some, but not urllib. Maybe urllib can do this,
but may I suggest checking out httplib:
http://docs.python.org/lib/httplib-examples.html
-ej
More information about the Python-list
mailing list