Python使用requests的Session对象自动发帖

原理
使用python脚本模拟发帖接口进行http请求

代码

import requests


url = 'https://mp.csdn.net/mdeditor/saveArticle'
payload = {
'title':'工作10年回头看',
'markdowncontent':'上述',
'content':'哈哈',
'private': '0',
'status':'2',
'channel':'0',
'type':'0',
'articleedittype':'1',
}
headers = {
'Accept':'',
'Accept-Encoding':'gzip, deflate, br',
'Referer':'https://mp.csdn.net/mdeditor',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
'cookie': r'',
}

with requests.Session() as s:
    r = s.post(url=url, data=payload,headers=headers)
    print(r.text)

请求参数url, data, headers查找方法
这里写图片描述

猜你喜欢

转载自blog.csdn.net/lylfv/article/details/82318031
今日推荐