def get_request(url, outfpath=None):
global PYCURL
if PYCURL:
# outfpath must be set
import pycurl
from io import BytesIO
buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, url)
c.setopt(c.WRITEDATA, buffer)
c.setopt(c.COOKIEJAR, '/tmp/cookie.jar')
c.setopt(c.NETRC, True)
c.setopt(c.FOLLOWLOCATION, True)
#c.setopt(c.REMOTE_NAME, outfpath)
c.perform()
c.close()
return buffer.getvalue()
resp = requests.get(url)
return resp.text
评论列表
文章目录