首先说明:这里面没啥太深的技术含量,都是一些老套的,比较低级的用法。而且本人代码写的很烂,希望看到后别喷。以下是正文

一、每日自动化签到
有些 app 里有签到,签到获得积分或者优惠券,比如我们公司每日 10 积分(价值 1 角),饿了么 app 水果超市 50 金币兑换 39 减 10 大红包,以及每日签到的满减券。
但是这些签到不可能每天都要人手动去点,太麻烦了,所以我们为什么不用脚本去跑呢?
原理:写一个签到接口,然后用定时任务工具去跑

#每日签到
url2="https://h5.ele.me/restapi/marketing/v1/wechat_signin/users/321606090"

cookie={'SID': 'mKWw1DXUdMiQlUs7hO8DhLDsJlkpQ0OCAybw', ' USERID': '321606090', ' isg': 'BLOzYuZ37LPFqaBnZl-ui7pbSLPd6EeqEK2552VQC1IJZNcG-rnc-y9_GlIvX5-i', ' track_id': '1542009860|9308d7b20438046725282d939f7beb334c407d1e1ae068ad58|caf69cba2bf958fe64392f614c53ec7d', ' _utrace': 'f2cf00483c9340d8d691d626be6b35cb_2018-11-12', ' cna': '3yFwFJRdDy4CAXxKS87k7Y4x', ' ubt_ssid': 'fbfi1uucahi2cgqnb505iicptvjmbusg_2018-11-12', ' perf_ssid': '32n7xavqjclo57flepe54e67cxzus0ej_2018-11-12'}
cookie2=requests.utils.cookiejar_from_dict(cookie)
#Ast2="sign_series"
res2=requests.post(url2,cookies=cookie2)
res2=requests.post(url2,cookies=cookie2).content.decode('utf-8')
logging.info("饿了么每日签到----------"+res2)

我的定时任务用的是 linux 自带的 crontab,设置每天 8:30 执行:30 08 * * * python /my/python/AutoSign/AutoSign.py
以下是日志:

Tue, 20 Nov 2018 08:30:03 AutoSign.py[line:28] INFO {"retCode":0,"retMsg":"成功","retData":{"totalPoint":1867,"incrementalPoint":10,"showPointList":null,"consecutiveDays":20},"retHtml":"","time":1542673803}
Tue, 20 Nov 2018 08:30:04 AutoSign.py[line:43] INFO {"retCode":0,"retMsg":"成功","retData":{"totalPoint":8165,"incrementalPoint":10,"showPointList":null,"consecutiveDays":16},"retHtml":"","time":1542673804}
Tue, 20 Nov 2018 08:30:04 AutoSign.py[line:56] INFO {"success": true, "data": {"sign_series": 20, "point": 7}, "code": 0, "message": ""}
Tue, 20 Nov 2018 08:30:05 AutoSign.py[line:83] INFO 饿了么每日签到----------{"amount":4,"sum_condition":30}
Tue, 20 Nov 2018 08:30:05 AutoSign.py[line:90] INFO 饿了么每日翻牌----------{"message":"路由不存在","name":"ROUTE_NOT_FOUND"}
Tue, 20 Nov 2018 08:30:05 AutoSign.py[line:95] INFO 饿了么会员签到----------[]
Tue, 20 Nov 2018 08:30:05 AutoSign.py[line:100] INFO 饿了么会员翻牌----------{"coin":66,"deduction_hongbaos":[{"amount":3,"descriptions":["限自动续费使用"],"name":"抵扣红包","sum_condition":6},{"amount":7,"descriptions":["限自动续费使用"],"name":"抵扣红包","sum_condition":10}],"double_card":["连续签到3天:3元红包X2","连续签到7天:7元红包X2"],"hongbaos":[{"amount":4,"descriptions":["限13:00-17:00时段使用"],"name":"下午茶红包","sum_condition":30}],"quality_hongbaos":[{"amount":3,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":39}],"type":5}
Tue, 20 Nov 2018 08:30:05 AutoSign.py[line:105] INFO 饿了么水果超市签到----------{"error_no":0,"error_msg":"","result":{"points_total":85,"sign_in_week_status":[1,1,0,0,0,0,0],"got_points":1,"future_sign_in":{"left_num":1,"extra_points":3},"sign_in_button_status":{"has_already_sign_in":true,"is_new_sign_in":false}}}
Tue, 20 Nov 2018 08:30:05 AutoSign.py[line:112] INFO 东方财富签到----------{"Result":{"SignDateList":null,"Score":6,"TomorrowScore":6,"Signed_Day":8,"Sign_Date":"2018-11-20","SystemTime":"\/Date(1542673805664)\/","IsSigned":true,"TotalScore":167,"Code":0},"Status":0,"Message":"OK","OtherInfo":{}}

二、定时抢饿了么 10 元无门槛大红包
说明:不一定每次都能抢成功,因为即使你用机器设定 17:00:00 去抢,那些红包也会在 0.1s 内被抢完,机器去抢比人手工去抢的概率大些。

#!/usr/bin/python
#-*- coding: UTF-8 -*-
import requests
import logging
import os
import sys
import codecs
import threading,datetime,time
#sys.setdefaultencoding('utf-8')
time_now = datetime.datetime.now().strftime('%H:%M:%S.%f')

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    #filename=os.path.dirname(__file__)+'/elem.log',
                    filemode='a')

logging.info("start time"+time_now)
def hongbao():
    cookie = {'SID': 'mKWw1DXUdMiQlUs7hOwDhLDsJlkpw0OCAybw', ' USERID': '321606090',
              ' isg': 'BLOzYuZ37LPFqaBnZl-ui7pbSLPd6EeqEK2552VQC1IJZNcG-rnc-y9_GlIvX5-i',
              ' track_id': '1542009860|9308d7b20438040825282d939f7beb334c407d1e1ae068ad58|caf69cba2bf958fe64392f614c53ec7d',
              ' _utrace': 'f2cf00483c9340d8d691d626be6b35cb_2018-11-12', ' cna': '3yFwFJRdDy4CAXxKS87k7Y4x',
              ' ubt_ssid': 'fbfi1uucahi2cgqnb505iicptvjmbusg_2018-11-12',
              ' perf_ssid': '32n7xavqjclo57flepe54e67cxzus0ej_2018-11-12'}
    Agent="Rajax/1 Apple/iPhone7,1 iOS/12.1 Eleme/8.5.1 ID/3B0EE632-2E54-45F8-953F-6FB9AB9F8889; IsJailbroken/0 ASI/71CA293E-5FF6-4267-9954-D44BC8E3984E Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16B92 AliApp(ELMC/8.5.1)"

    cookie2 = requests.utils.cookiejar_from_dict(cookie)
    headers = {'User-agent': Agent}
    url2 = "https://h5.ele.me/restapi/member/v1/users/321606090/sign_in/limit/hongbao"
    data = {"user_id": 321606090, "latitude": 31.250972747802734, "longitude": 121.51678466796875}
    n = 0
    time.sleep(58.2)
    while n < 10:
        logging.info(datetime.datetime.now().strftime('%H:%M:%S.%f'))
        n = n + 1
        res2 = requests.post(url2, data,cookies=cookie2,headers=headers)\
            .content.decode('utf-8')
        logging.info(res2)
t=threading.Thread(target=hongbao,name='LoopThread')

t.start()
t.join()

代码里用了多线程,10 个线程并发去抢。不用超过 10 个线程,是因为饿了么对请求会做限制,甚至会加黑名单。另外 time.sleep(58.2),这个是因为 crontab 设置定时任务只能精确到分,当然如果用到 sleep n 可以精确到秒,但是代码里设置可以精确到毫秒。
本人最近只抢到了一次

Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 16:59:59.975402---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.034673---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.069965---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.104305---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.138706---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.174188---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.211707---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.244896---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 17:00:00 Thread-elem.py[line:37] INFO 17:00:00.280467---------[{"amount":10,"descriptions":["品质商家联盟用户专享"],"name":"品质联盟红包","sum_condition":0}]
Mon, 19 Nov 2018 20:00:00 Thread-elem.py[line:37] INFO 20:00:00.460852---------{"message":"每个用户一天只能领取一个红包","name":"FLASH_HONGBAO_FAILED"}
Mon, 19 Nov 2018 20:00:00 Thread-elem.py[line:37] INFO 20:00:00.506125---------{"message":"每个用户一天只能领取一个红包","name":"FLASH_HONGBAO_FAILED"}

总结:
现在有些宣传,说是使用 app 还可以赚钱,比如下载某 app 然后玩游戏,返现。趣头条里完成 app 每日任务,获得金币兑换现金。如果可以把这些任务,用脚本完成,然后用机器代替人工执行,那么就每天啥都不做,都会有一些额外的外快进账啦。


↙↙↙阅读原文可查看相关链接,并与作者交流