自动发帖子-博客园
Posted amelia0201
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动发帖子-博客园相关的知识,希望对你有一定的参考价值。
1、登录博客园,抓包获取cookies
from requests.api import post
import random
def addContent(title = ‘你好python3‘,content=‘你好python3‘):
‘‘‘写随笔保存草稿‘‘‘
url = ‘https://i.cnblogs.com/EditPosts.aspx?opt=1‘
headers = {‘Cookie‘:‘_ga=GA1.2.1239636619.1534329060;‘
‘ __gads=ID=bfefe72e2a21ad5b:T=1541037898:S=ALNI_MbFt9qMBHRjgWHO5NMfo9iXfkuoWw;‘
‘ _gid=GA1.2.1433240614.1543390209; ‘
‘.CNBlogsCookie=‘
‘C1AC0E7CF1CC40B40D6B30FCA33A0898DAAD80D2CE394C9BD35A6863FA6B61F9646D5AD61F401B‘
‘26305AE5902525CD0CDC9C647C9D28892462CFE993771774906562F62AB4A610E30E2142ECDD72‘
‘D0D3D3DAA523; .Cnblogs.AspNetCore.Cookies=CfDJ8KlpyPucjmhMuZTmH8oiYTNBz_YdK1q6‘
‘WQe1JmYSa4hlL_RqUvfpnpPxtGmZZ-l9Voz1JN5vUxaOzCfi_r0b-bbg72-WWdjGCh67Zct-Y2NEiC‘
‘spRaVYrO2VX2oRph1By4w3D-cJXNA9qRS7RV--bfzZxAysQuxyPwrvZPr-wLizCH3-k26RNlDxE8aT‘
‘blYMQZJ9hQdig08hFKlrHv7mUaK1yPDSl3IR3AvLeG8G1QrsJLjVUdOnnLkgeQmKWWj0BmRRtpUxNk‘
‘J6usi8mRTbE_nFZKUG6Ek4Ts7ieAEg4wSW; _gat=1; ‘
‘SERVERID=a15b3bd10716e69d8be538bb89e87a05|1543473819|1543473623‘}
data = {‘__VIEWSTATE‘:‘‘,
‘__VIEWSTATEGENERATOR‘:‘FE27D343‘,
‘Editor$Edit$txbTitle‘:‘title‘,
‘Editor$Edit$EditorBody‘:‘<p>%s</p>‘%content,
‘Editor$Edit$Advanced$ckbPublished‘:‘on‘,
‘Editor$Edit$Advanced$chkDisplayHomePage‘:‘on‘,
‘Editor$Edit$Advanced$chkComments‘:‘on‘,
‘Editor$Edit$Advanced$chkMainSyndication‘:‘on‘,
‘Editor$Edit$Advanced$txbEntryName‘:‘‘,
‘Editor$Edit$Advanced$txbExcerpt‘:‘‘,
‘Editor$Edit$Advanced$txbTag‘:‘‘,
‘Editor$Edit$Advanced$tbEnryPassword‘:‘‘,
‘Editor$Edit$lkbDraft‘:‘存为草稿‘}
res = post(url=url,data=data,headers=headers,verify=False)
return res
addContent(title = random.randint(1,100),content=random.randint(1,100))
保存为草稿,自动化脚本完成
以上是关于自动发帖子-博客园的主要内容,如果未能解决你的问题,请参考以下文章