Python解决web基础$_POST 30

#POST请求的数据保存在表单中dict

#利用字典dict = {'what':'flag'}可以达到这一要求


from urllib import request,parse

url = "http://123.206.87.240:8002/post/"

headrs = {

'User-Agent':"Mozilla/4.0 (compatible; MSIE 5.5;Windows NT)",

'Host':'httpbin.org'

}

dict = {'what':'flag'}

data = bytes(parse.urlencode(dict),encoding='utf8')

req = request.Request(url=url,data=data,headers=headrs,method='POST')

response = request.urlopen(req)

print(response.read().decode('utf-8'))

image

image
posted @ 2018-10-20 11:11  Osword  阅读(747)  评论(0编辑  收藏  举报