I'm using the following piece of code to get the content of a webpage from python script:
#!/usr/bin/env python
import pycurl
import StringIO
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://google.com")
b = StringIO.StringIO()
c.setopt( c.WRITEFUNCTION, b.write)
#c.setopt(pycurl.COOKIESESSION, True);
c.setopt(pycurl.COOKIEFILE, "/tmp/cookiefile.txt");
c.setopt(pycurl.COOKIEJAR, "/tmp/cookiefile.txt");
c.perform()
page_data = b.getvalue()
For some reason
c.setopt(pycurl.COOKIESESSION, True);
gives an error. Does anybody know if this option is supported in pycurl?
Thanks in advance.
I'm sorry but this option is not supported in pycurl, but as I can see in the source code, it should be a fairly easy fix. You should ask for it on the curl and python mailing list .
This fixes the Problem:
import pycurl
pycurl.COOKIESESSION = 96
我想删除cookiefile与将COOKIESESSION设置为True具有相同的效果。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.