码迷,mamicode.com
首页 > 其他好文 > 详细

自动发帖子-博客园

时间:2018-11-30 14:10:35      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:exce   net   who   9.1   stat   body   e30   lis   nts   

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

保存为草稿,自动化脚本完成

 

自动发帖子-博客园

标签:exce   net   who   9.1   stat   body   e30   lis   nts   

原文地址:https://www.cnblogs.com/Amelia0201/p/10043206.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!