Re: Python equivalent of LWP and HTTP in Perl
From: Michael Foord (fuzzyman_at_gmail.com)
Date: 10/29/04
- Next message: Diez B. Roggisch: "Re: C API q"
- Previous message: Jaime Wyant: "Re: Writing a Python font viewer/manager"
- In reply to: Dekaritae: "Python equivalent of LWP and HTTP in Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Oct 2004 05:54:31 -0700
Dekaritae <maur@mdi.ca> wrote in message news:<vAbgd.24$SJ2.18@fe61.usenetserver.com>...
> I have a script that I've written in Perl that retrieves files generated
> from a template. It works decently enough, but I'd like to rewrite it in
> Python (Perl was just a detour; it was originally Sed).
>
> Was wondering what the closest thing to what I'm using now in Perl
> (LWP::UserAgent and HTTP::Request:Common) is in Python. The main bit of
> my code is fairly simple.
>
> 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;
urllib2 is definitely the way forward for adding proxy support and
request headers. Very easy. If you want cookie handling you'll need to
look at ClientCookie which does similar things to the perl library you
mention.
Regards,
Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html
- Next message: Diez B. Roggisch: "Re: C API q"
- Previous message: Jaime Wyant: "Re: Writing a Python font viewer/manager"
- In reply to: Dekaritae: "Python equivalent of LWP and HTTP in Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|