[Zope-Perl] LWP

Gisle Aas gisle@ActiveState.com
26 May 2000 12:29:31 +0200


Yet another demo of a random CPAN module invoked from Python :-)

$ python
Python 1.6a2 (#5, May 24 2000, 22:38:33)  [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
>>> import perl
>>> perl.require("LWP")
1
>>> ua = perl.callm("new", "LWP::UserAgent")
>>> req = perl.callm("new", "HTTP::Request", "GET", "http://www.python.org")
>>> res = ua.request(req)
>>> print res.status_line()
200 OK
>>> print res.headers().as_string()
Connection: close
Date: Fri, 26 May 2000 10:22:58 GMT
Accept-Ranges: bytes
Server: Apache/1.3.9 (Unix)
Content-Length: 13509
Content-Type: text/html
ETag: "7418e-34c5-39227cae"
Last-Modified: Wed, 17 May 2000 11:04:14 GMT
Client-Date: Fri, 26 May 2000 10:24:09 GMT
Client-Peer: 132.151.1.90:80
Title: Python Language Website
X-Meta-Description: Home page for Python, an
 interpreted, interactive, object-oriented, extensible
 programming language.  It provides an extraordinary combination
 of clarity and versatility, and is free and comprehensively
 ported.
X-Meta-Keywords: Python programming language
 object oriented web free source

>>> print res.content()[:40]
<HTML>
<!-- THIS PAGE IS AUTOMATICALLY G
>>>