4e49465c5beb6ff02730d9ad06ccf4cf53c560d5
[plcapi.git] / pycurl / examples / basicfirst.py
1 #! /usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3 # vi:ts=4:et
4 # $Id: basicfirst.py,v 1.5 2005/02/11 11:09:11 mfx Exp $
5
6 import sys
7 import pycurl
8
9 class Test:
10     def __init__(self):
11         self.contents = ''
12
13     def body_callback(self, buf):
14         self.contents = self.contents + buf
15
16 print >>sys.stderr, 'Testing', pycurl.version
17
18 t = Test()
19 c = pycurl.Curl()
20 c.setopt(c.URL, 'http://curl.haxx.se/dev/')
21 c.setopt(c.WRITEFUNCTION, t.body_callback)
22 c.perform()
23 c.close()
24
25 print t.contents