网络请求模块 urllib(标准模块)python操作网络,也就是打开一个网站,或者请求一个http接口,使用urllib模块
用到模块中 request parse 两个方法
由于urllib模块,传参麻烦,需要把字典类型parse下变为k=v,post还要把参数转为二进制;接收的值是bytes类型,还要解码,变为字符串,同时直接用的话还要转为为json。比较麻烦。更好的就是用 第三方模块 request 模块
urllib模块 的 get请求
-----------------------------------------------
urllib模块 post请求
---------------------------------------------------------------------------------------------------------------------------------------------
*(requests模块)
get()请求 requests.get(url,data)
post请求 requests.post(url,data)
-----------------
post 请求 入参是 json类型的 可以通过在post请求中指定参数类型 requests.post(url,json=data)
-------------------
post 请求中存在 cookie 的,在请求中用 cookies 进行传递 requests.post(url,data,cookies=cook)
-----------
请求中有 header 的 直接在请求中通过headers 传递 requests.get(url,headers=header)
-------
把文件上传到服务器 请求中通过files进行传递 requests.post(url,files=file)
---------------------------------------------------------------------------
jsonpaht模块
jsonpaht.jsonpath(d,$..key)
---------------------------
写日志模块 nnlog