模拟伪造浏览器并获取json数据:

import requests
h = {
"user-agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"
}
response = requests.get(url="https://www.zhihu.com/question/362788804",headers = h)
print(response)
print(response.text)
j = {"username":"test","password":"1234","gender":1,"phoneNum":"110","email":"beihe@163.com","address":"Beijing"}
r = requests.post(url="http://www.neeo.cc:6002/pinter/com/register",json=j)
print(r.json())
posted @ 2020-01-17 20:17  干it的小张  阅读(434)  评论(0编辑  收藏  举报