Python-提交form表单

其中的d是一个字典类型,其中的键key1、key2…就是HTML前端代码form表单中的name属性值

value1、value2…就是用户提交的内容

requests.post用来提交post类型请求,requests.get用来提交get类型请求

r是一个requests.models.Response类型的对象,可以调用对象的text方法来获取返回包的文本内容

import requests
url = 'http://IP:端口/路径'
d = {
    
    'key1': 'value1', 'key2': 'value2'}
h = {
    
    'Content-Type': 'application/x-www-form-urlencoded'}
c = "cookie"
r = requests.post(url, data=d,headers=h,cookies=c)
print(r.text)

猜你喜欢

转载自blog.csdn.net/smallfox233/article/details/128109112