[Tutor] pycurl RETURNTRANSFER

Jay Dorsey python@jaydorsey.com
Thu Mar 6 15:31:41 2003


I'm trying to get a page returned in a variable using PyCurl, but it 
doesn't seem to have the RETURNTRANSFER option implemented.  Can anyone 
confirm/deny this for me, or is there some other way to get the page 
returned as a variable instead of a having to do a filewrite?

Below is how I'm currently working it, along with how I thought 
RETURNTRANSFER should be set, I *reallly* dont' want to have to do a 
file write though.

f = open('myfile','w')

cp = pycurl.Curl()
cp.setopt(cp.URL, 'http://www.msn.com/')
cp.setopt(cp.HEADER, 1)
cp.setopt(cp.NOPROGRESS, 1)
#cp.setopt(cp.REFERER, referer)
#cp.setopt(cp.COOKIE, cookie)
# the line below doesn't work
#cp.setopt(cp.RETURNTRANSFER, page)
# write the HTML page to a file
cp.setopt(cp.WRITEFUNCTION, f.write)
cp.perform()
cp.close()

Any help is appreciated.


-- 
Jay Dorsey
python at jay dorsey dot com