csdn自动签到python脚本

前言:csdn有个每日签到的小功能,本人有幸就抽中个杯子。但是呢,每天都要签,是不是有点麻烦。本着能用代码解决的就不动手,就是试了一下可不可以?站在前人的肩膀上加上自己的世间就成功了代码。

代码如下

import requests
import time
import json

headers = {
'accept':'application/json, text/plain, */*',
'accept-encoding':'gzip, deflate, br',
'accept-language':'zh-CN,zh;q=0.9',
'cache-control':'no-cache',
'content-length':'247',
'content-type':'application/json;charset=UTF-8',
'cookie':'uuid_tt_dd=10_21002145320-1569306368647-530289; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_21002145320-1569306368647-530289!5744*1*weixin_44146025; smidV2=20191005152519e1672eec8bb7335ddb17a4136f900bdb0026dd2b7087b3920; __gads=ID=0685ee9dbd699171:T=1586574128:S=ALNI_Ma-iLaOhW5baScFk231_hCbGvQ6ig; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1603427841,1604050694,1604221011; UN=weixin_44146025; p_uid=U010000; UserName=weixin_44146025; UserInfo=c73862634fbd43898c7a21a8056f5875; UserToken=c73862634fbd43898c7a21a8056f5875; UserNick=%E5%86%89%E7%AD%B1; AU=F33; BT=1611574167593; c_first_ref=default; c_first_page=https%3A//blog.csdn.net/weixin_44146025; c_segment=1; dc_sid=0e80cf352440f868d25db0d6f1bdc277; is_advert=1; c_page_id=default; c_ref=https%3A//blog.csdn.net/weixin_44146025; dc_session_id=10_1611727790454.373035; dc_tos=qnkx4f; log_Id_pv=905; log_Id_click=583',
'pragma':'no-cache',
'referer':'https://i.csdn.net/',
'sec-fetch-dest':'empty',
'sec-fetch-mode':'cors',
'sec-fetch-site':'same-site',
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
}
data = {
'ip':'',
'platform':'pc-my',
'product':'pc',
'user_agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
'username':'weixin_44146025',
'uuid':'10_21002145320-1569306368647-530289'
}
r = requests.post("https://me.csdn.net/api/LuckyDraw_v2/signIn",headers=headers,data=data)
now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
msg  = r.json()
try:
    with open('wenjian.txt', 'a') as f:
        f.write('{} --- {}\n'.format(now, msg))
        f.close()
        print(msg)
except Exception as e:
    print(e)

 至于head和date怎么获取,就是你先按F12,再签到抽奖,在调试器里找到对应标签,复制下来就行,注意经过我的测试,这几个是必须的,而且,csdn有反爬措施,cookie加密过,目前最新的规则,按我的这个格式就能过(呜呜呜,试验了个把小时,侥幸过了)

csdn自动签到python脚本_第1张图片

 
相关文章


将headers请求头字符串转为字典:https://blog.csdn.net/weixin_44146025/article/details/113249043?spm=1001.2014.3001.5501

在阿里云服务器Centos 7中部署python脚本:https://blog.csdn.net/weixin_44146025/article/details/113249961?spm=1001.2014.3001.5501

你可能感兴趣的:(服务器)