requests库来模拟请求
1
2
3
4
5
6
7
8
9
10
11#test header
headers = { "Accept":"text/html,application/xhtml+xml,application/xml;",
"Accept-Encoding":"gzip",
"Accept-Language":"zh-CN,zh;q=0.8",
"Referer":"http://www.example.com/",
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36",
"myuser": 'hello',
}
payload = {'user_id': 11, 'token': 'token', 'is_reported': 25, 'content': u'不正当经营', 'is_activity': True}
r = requests.get('http://localhost:9000/test/', data=payload, headers=headers)
print r.textrequest请求头信息的键会加上HTTP_转换成大写存到request.META中
1 | def test(request): |
django官网的解释:
1 | HttpRequest.META |