Python解决web基础$_POST 30,零基础web开发,#POST请求的数据


#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‘))

技术分享图片

技术分享图片

Python解决web基础$_POST 30

评论关闭