Which is best in Python: urllib2, PycURL or mechanize?

前端 未结 8 1445
一个人的身影
一个人的身影 2021-01-29 17:48

Ok so I need to download some web pages using Python and did a quick investigation of my options.

Included with Python:

urllib - seems to me that I should use ur

8条回答
  •  太阳男子
    2021-01-29 18:00

    Python requests is also a good candidate for HTTP stuff. It has a nicer api IMHO, an example http request from their offcial documentation:

    >>> r = requests.get('https://api.github.com', auth=('user', 'pass'))
    >>> r.status_code
    204
    >>> r.headers['content-type']
    'application/json'
    >>> r.content
    ...
    

提交回复
热议问题