先手动发送一个草稿,然后用fiddler取到body参数

代码:

#coding:utf-8
import requests login_url="https://passport.cnblogs.com/user/signin"
#login_url="https://www.baidu.com"
header={
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
}
s=requests.session()#实例 seesion保持会话
r1=s.get(login_url,headers=header,verify=False)
#添加前的cookie
print r1.cookies #添加cookie到session
#添加登录需要的两个cookie
c=requests.cookies.RequestsCookieJar()
# c.set("BAIDUID","B98C2B44340932F96B4DDE7BDABE62ED:FG=1")
# c.set("BDUSS","hnbUl0cXdEclBnZGRtLTMxeGZaWWdxT0oxYzVpdGJVfktOUVM2REZDSWxlVnRhQVFBQUFBJCQAAAAAAAAAAAEAAAC4s8IX5v3nq9fTtdyh5QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACXsM1ol7DNaOU")
c.set(".CNBlogsCookie","13F5D78C3950299ADAFCC282FBA8FCC01B9B8B86AD295EF6002808ABF50CE381F7D8357327690F40E49128DF7273353F168072CA186225FA70091F13429569D7F3908CBF8C2D2684DD3F44A4D58F94C22655D88")
c.set(".Cnblogs.AspNetCore.Cookies","CfDJ8N7AeFYNSk1Put6ydpme2atOlPXjB0Ulecl4pfCjN7jr5qhwaR9EIfhpY_hvJ0hbtBj-QS1S0Ku7gSehBh3TiNcPwJDUP2K802RKQQ8i82llnK_JyWE7ZkR4di5rbWnqB7Y8vzGoki-o5YJEKWdfrv3cCV1dNtmY5mrS1JqzFIeuVjOCMmyhLxX_e2TmadIzkHJSxBiUK-UiIy7JaAmsFk_8GDverEDwr1JlngWSiZXoQHyb7juJRsMEbQU3iimTtUyhZCl628g-EIAmtz0mfEfjvHT9J17QBKNf4HYqW0VDei47uNa_8n010rLJe8TUg")
#追加
print s.cookies.update(c) #添加后的cookie
print r1.cookies #保存草稿箱
#bianji_url="https://passport.baidu.com/center?_t=1513352285"
bianji_url="https://i.cnblogs.com/EditPosts.aspx?opt=1"
body={
"__VIEWSTATE":"",
"__VIEWSTATEGENERATOR":"FE27D343",
"Editor$Edit$txbTitle":"linbao",
"Editor$Edit$EditorBody":"<p>的的的</p>",
"Editor$Edit$APOptions$Advancedpanel1$cklCategories$2":"1130614",
"Editor$Edit$Advanced$ckbPublished":"on",
"Editor$Edit$Advanced$chkDisplayHomePage":"on",
"Editor$Edit$Advanced$chkComments":"on",
"Editor$Edit$Advanced$chkMainSyndication":"on",
"Editor$Edit$lkbDraft":"存为草稿"
}
r2=s.post(url=bianji_url,data=body,verify=False)
print r2.content
05-11 10:52