pycurl example: pycurl frequently used options

c = pycurl.Curl()
c.setopt(pycurl.VERBOSE,1)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
#c.setopt(pycurl.AUTOREFERER,1)
#c.setopt(pycurl.COOKIEJAR,"dasfa")
c.setopt(pycurl.CONNECTTIMEOUT, 60)
c.setopt(pycurl.TIMEOUT, 300)
if proxy:
c.setopt(pycurl.PROXY,proxy)
c.setopt(pycurl.NOSIGNAL, 1)

c = pycurl.Curl()
c.setopt(pycurl.VERBOSE,1)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
#c.setopt(pycurl.AUTOREFERER,1)
#c.setopt(pycurl.COOKIEJAR,"dasfa")
c.setopt(pycurl.CONNECTTIMEOUT, 60)
c.setopt(pycurl.TIMEOUT, 300)
if proxy:
c.setopt(pycurl.PROXY,proxy)
c.setopt(pycurl.NOSIGNAL, 1)
c.fp = StringIO.StringIO()
random.seed()
c.setopt(pycurl.USERAGENT,
"""Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7""")
c.setopt(pycurl.URL, url)
c.setopt(c.WRITEFUNCTION, c.fp.write)
c.perform()

Leave a Reply

Your email address will not be published. Required fields are marked *