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

一个游戏活动的代码

时间:2021-04-27 14:10:35      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:content   flat   hang   res   text   get   stat   次数   verify   

运行环境python3.7

#coding=utf-8
import requests
import time
import json
import re
import sqlite3
url=[]
for i in open("AURL.txt"):
    url.append(i)
yaoqing=url[0]
accountId=re.findall(‘accountId=(.*?)&gameRoleId‘,yaoqing)[0]
gameRoleId=re.findall(‘&gameRoleId=(.*)‘,yaoqing)[0]
cookietext="PHPSESSID=pknnvc416nd73rkbrrqcrenpn6; Hm_lvt_a4f2feaf9a7d1010d357c20624f96072=1618965725,1618983130; sid=; phone=; Hm_lpvt_a4f2feaf9a7d1010d357c20624f96072=1618983163"
headers={
 "Origin": "http://wxplatform.yunchanggame.com",
 "Accept-Language": "zh-CN,zh;q=0.9",
 "Accept-Encoding": "gzip, deflate",
 "Connection": "keep-alive",
 "Accept": "application/json, text/javascript, */*; q=0.01",
 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
 "Host": "wxplatform.yunchanggame.com",
 "X-Requested-With": "XMLHttpRequest",
 "Cookie": "%s"%cookietext,
 "Referer": "http://wxplatform.yunchanggame.com/expedition/index/index?accountId=%s&gameRoleId=%s"%(accountId,gameRoleId),
 "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
#验证码接收平台登录取号
def sm_code():
    url="http://api.do889.com:81/api/logins?username=你的账户&password=你的密码"
    get_token=json.loads(requests.get(url).text)
    tokens=get_token["token"]
    data_list=[tokens]
    money=get_token["data"][0]["money"]
    print("【验证码平台】余额:%s"%(money))
    url2="http://api.do889.com:81/api/get_mobile?token=%s&project_id=64511"%tokens
    get_sm=json.loads(requests.get(url2).text)
    if get_sm["message"]=="ok":
        print(get_sm["message"])
        data_list.append(get_sm["mobile"])
        print("【验证码平台】号码获取成功:%s" % sm_num)
        return data_list
    else:
        print("【验证码平台】%s"%get_sm["message"])
        exit()

#活动页验证码获取
def helpme():
    data_list=sm_code()
    url="http://wxplatform.yunchanggame.com/expedition/verify/get_sms"
    data=‘phone=%s‘%data_list[1]
    #请求发送验证码
    print("【活动服务器】请求发送验证码")
    go=requests.post(url,headers=headers,data=data)
    #接收平台验证码
    url2="http://api.do889.com:81/api/get_message?token=%s&project_id=64511&phone_num=%s"%(data_list[0],data_list[1])
    for i in range(1, 5):
        num_code = json.loads(requests.get(url2).text)
        if "code" in num_code:
            print("【验证码平台】接收验证码成功:%s"%(num_code["code"]))
            data_list.append(num_code["code"])
            break
        else:
            if i >4:
                print(("【验证码平台】获取失败,请求释放号码" % i))
                shifang=json.loads(requests.get("http://api.do889.com:81/api/free_mobile?token=%s&phone_num=%s"%(data_list[0],data_list[1])).text)
                print("【验证码平台】释放状态:%s,准备退出程序,请检查问题"%shifang["message"])
                exit()
            print(("【验证码平台】等待验证码中,第%s次"%i))
            time.sleep(5)

    return data_list
#提交赠送可乐
def yue():
    data_list=helpme()
    #登录
    url="http://wxplatform.yunchanggame.com/expedition/verify/check_sms"
    data=‘phone=%s&sms_code=%s‘%(data_list[1],data_list[2])
    go=requests.post(url,headers=headers,data=data)
    results=json.loads(go.text)
    text=go.headers
    setcookies=re.findall(r‘sid=(.*?); expires‘, text["Set-Cookie"])
    print("【活动服务器】设置cookie:%s"%setcookies[0])
    cookietext = "PHPSESSID=pknnvc416nd73rkbrrqcrenpn6; Hm_lvt_a4f2feaf9a7d1010d357c20624f96072=1618965725,1618983130;Hm_lpvt_a4f2feaf9a7d1010d357c20624f96072=1618983163; sid=%s; phone=%s"%(setcookies[0],data_list[1])

    okheaders = {
        "Host": "wxplatform.yunchanggame.com",
        "Origin": "http://wxplatform.yunchanggame.com",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Accept-Encoding": "gzip, deflate",
        "Connection": "keep-alive",
        "Accept": "application/json, text/javascript, */*; q=0.01",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
        "X-Requested-With": "XMLHttpRequest",
        "Cookie": "%s" % cookietext,
        "Referer": "http://wxplatform.yunchanggame.com/expedition/index/index?accountId=%s&gameRoleId=%s" % (
        accountId, gameRoleId),
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    url3="http://wxplatform.yunchanggame.com/expedition/index/give_rose"
    data=‘accountId=%s&gameRoleId=%s‘%(accountId,gameRoleId)
    huoqu=json.loads(requests.post(url3,headers=okheaders,data=data).text)
    print(huoqu["tips"])
    url4="http://wxplatform.yunchanggame.com/expedition/index/lottery"
    chou = json.loads(requests.post(url4, headers=okheaders, data=data).text)
    filenames="di1.txt"

    if huoqu["tips"] == "赠送成功":
        print(u"【活动服务器】%s,赠送%s个" % (huoqu["tips"], huoqu["grant_num"]))
        sqlin(setcookies[0], data_list[1], "0")
        url4 = "http://wxplatform.yunchanggame.com/expedition/index/lottery"
        chou = json.loads(requests.post(url4, headers=okheaders, data=data).text)
        if chou["tips"] == u"操作成功":
            print((chou["title"]))
            with open("%s" % filenames, "a") as f:
                f.write("%s----%s----%s" % (setcookies[0], data_list[1], chou["title"]) + "\n")
        else:
            print((chou["tips"]))
        return "ok"
    elif u"解锁" in huoqu["tips"]:
        sqlin(setcookies[0], data_list[1], "1")
        print("%s,退出程序") % (huoqu["tips"])
        exit()
    else:
        print((huoqu["tips"]))
        return "no"

#数据库更新
def sqlin(cookie, phone, status):
    surp = 0
    # 0为赠送成功,1为失败,失败的话不减少次数
    if status == "0":
        # 因为是新号第一次邀请,所以剩下两次
        surp = 2
    if surp == "1":
        surp = 3
    conn = sqlite3.connect(‘sqlite.db‘)
    c = conn.cursor()
    c.execute("INSERT INTO onepiece (cookie,phone,surp) VALUES (‘%s‘,‘%s‘,‘%s‘)" % (cookie, phone, surp))
    conn.commit()
    conn.close()



if __name__ == ‘__main__‘:
    print("模块名称:新注册号赠送")
    for i in range(1,int(eval(input("人数:")))+1):
        yue()

一个游戏活动的代码

标签:content   flat   hang   res   text   get   stat   次数   verify   

原文地址:https://www.cnblogs.com/cbreeze/p/14702001.html

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