Skip to content

Instantly share code, notes, and snippets.

@leotop
Created June 28, 2014 21:20
Show Gist options
  • Save leotop/aa6e23456a648052cdd3 to your computer and use it in GitHub Desktop.
Save leotop/aa6e23456a648052cdd3 to your computer and use it in GitHub Desktop.
python3 pycurl
import pycurl
import io
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://www.leotop.org/")
c.setopt(pycurl.HTTPHEADER, ["Accept:"])
b = io.BytesIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.MAXREDIRS, 5)
c.perform()
print(b.getvalue().decode('UTF-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment