-
pip --version 查看 pip 版本 pip -h 查看 pip 的功能(或者 pip --help) pip freeze 查看当前安装了那些包 requests 相当于寄信人,httpbin 相当于收信人(服务端)
http://httpbin.org/
查看全部 -
1.http://docs.python-requests.org/en/master/ requests类库网址
查看全部 -
python3代码
import urllib.request import urllib.parse """ 在Python2.x中使用import urllib2——-对应的,在Python3.x中会使用import urllib.request,urllib.error。 在Python2.x中使用import urllib——-对应的,在Python3.x中会使用import urllib.request,urllib.error,urllib.parse。 在Python2.x中使用import urlparse——-对应的,在Python3.x中会使用import urllib.parse。 在Python2.x中使用import urlopen——-对应的,在Python3.x中会使用import urllib.request.urlopen。 在Python2.x中使用import urlencode——-对应的,在Python3.x中会使用import urllib.parse.urlencode。 在Python2.x中使用import urllib.quote——-对应的,在Python3.x中会使用import urllib.request.quote。 在Python2.x中使用cookielib.CookieJar——-对应的,在Python3.x中会使用http.CookieJar。 在Python2.x中使用urllib2.Request——-对应的,在Python3.x中会使用urllib.request.Request。 """ URL_IP = 'http://127.0.0.1:8000/ip' URL_GET = 'http://127.0.0.1:8000/get' def use_simple_urllib(): response = urllib.request.urlopen(URL_IP) print('>>>Response Header:') print(response.info()) print('>>>Response Body:') print(response.read().decode()) def use_params_urllib(): # 构建请求参数 params = urllib.parse.urlencode({'name': 'hello world!', 'age': '18'}) print('Request Params:', params) # 处理响应 response = urllib.request.urlopen('?'.join([URL_GET, '%s']) % params) print('>>>Response Header:', response.info()) print('>>>Status Code:', response.getcode()) print('>>>Response Body:', response.read().decode()) if __name__ == '__main__': use_simple_urllib() use_params_urllib()
查看全部 -
session 服务器端保存储用户信息, 状态
cookie 浏览器存储信息
查看全部 -
自定义request
查看全部 -
什么是http协议? HyperText Transfer Protocol 超文本传输协议 HTTP是一种无状态的应用层协议,分布式,协作式超文本信息系统. 互联网的基石
查看全部 -
这里有讲oauth认证,类似qq登录
查看全部 -
gunicorn这个是用来干什么用的?可以直接爬取网站?
查看全部 -
下载图片时:
request中指定流stream=True
使用contextlib下的closing关闭response流
查看全部 -
gunicorn + httpbin 来做测试服务器
gunicorn httpbin:app
查看全部 -
查看全部
-
查看全部
-
查看全部
-
查看全部
-
查看全部
举报
0/150
提交
取消