返回顶部

收藏

python HTTP 客户端库–requests介绍

更多
>>> import requests
>>> requests.get('http://outofmemory.cn',)
<Response [200]>
>>> req = requests.get('http://outofmemory.cn')
>>> req.url
u'http://outofmemory.cn/'
>>> dir(req)
['__bool__', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '_
_hash__', '__init__', '__module__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr
__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_content', '_conten
t_consumed', 'apparent_encoding', 'close', 'connection', 'content', 'cookies', 'encoding', 'headers'
, 'history', 'iter_content', 'iter_lines', 'json', 'links', 'ok', 'raise_for_status', 'raw', 'reason
', 'request', 'status_code', 'text', 'url']
>>> req.status_code
200
>>> len(req.text)
424891
>>> help(requests.get)
Help on function get in module requests.api:

get(url, **kwargs)
    Sends a GET request. Returns :class:`Response` object.

    :param url: URL for the new :class:`Request` object.
    :param \*\*kwargs: Optional arguments that ``request`` takes.

标签:python,http,requests

收藏

0人收藏

支持

0

反对

0

发表评论