python3中的urllib的post请求的使用,以访问拉钩为例,虽然出现操作太频繁的运行,但是也可以熟悉下相关post请求的操作。
import urllib.request #拉钩fiddle抓包POST https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false data="first=true&p=1&kd=python" headers={"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"} request=urllib.request.Request("https://www.lagou.com/jobs/positionAjax.json?",headers=headers) urllib.request.data = "Some data" #post操作 response=urllib.request.urlopen(request).read() print(response.decode("utf-8"))