日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python抽卡游戏_【python爬虫】原神公测预抽卡活动自动化抽卡脚本(一小时免登陆)...

發(fā)布時(shí)間:2023/12/10 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python抽卡游戏_【python爬虫】原神公测预抽卡活动自动化抽卡脚本(一小时免登陆)... 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

[Python] 純文本查看 復(fù)制代碼import requests

import json

import time

#pyinstaller -D -i favicon.ico crawl.py

class Crawl():

#初始化cookies

def __init__(self):

self.login_ticket = "";

self.account_id="";

self.login_uid="";

self.cookie_token="";

#get請(qǐng)求

def get(self,url):

payload = {}

headers = {

'Cookie': 'login_uid='+self.login_uid+'; account_id='+self.account_id+'; login_ticket='+self.login_ticket+'; cookie_token='+self.cookie_token,

}

response = requests.request("GET", url, headers=headers, data = payload)

return json.loads(response.text)

#post請(qǐng)求

def post(self,url,data):

headers = {

'Cookie': 'login_uid='+self.login_uid+'; account_id='+self.account_id+'; login_ticket='+self.login_ticket+'; cookie_token='+self.cookie_token

}

response = requests.request("POST", url, headers=headers, data = data)

return json.loads(response.text)

def post2(self,url):

headers = {

'Cookie': 'login_uid='+self.login_uid+'; account_id='+self.account_id+'; login_ticket='+self.login_ticket+'; cookie_token='+self.cookie_token

}

response = requests.request("POST", url, headers=headers, data = {})

return json.loads(response.text)

#獲取以獲得的物品

def item_list(self):

url = "https://api-takumi.mihoyo.com/event/e20200828bingo/item_list"

res = self.get(url)

return res

#分享

def share(self):

url = "https://api-takumi.mihoyo.com/event/e20200828bingo/share"

res = self.get(url)

return res

#獲取基本信息,是否分享,還剩翻卡次數(shù)

def home(self):

url ="https://api-takumi.mihoyo.com/event/e20200828bingo/home"

res = self.get(url)

return res

#獲取驗(yàn)證碼

def getCaptcha(self,mobile):

body ={"action_type":"login","t":"1599809011444","mobile":mobile}

url = "https://webapi.account.mihoyo.com/Api/create_mobile_captcha";

res = self.post(url,body)

return res

def login(self,mobile,captcha):

body ={"mobile_captcha":captcha,"is_bh2":"false","action_type":"login","t":"1599809011444","mobile":mobile}

url = "https://webapi.account.mihoyo.com/Api/login_by_mobilecaptcha";

headers = {

'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36',

}

session = requests.session()

response = session.post(url, headers=headers, data = body)

res = json.loads(response.text)

if(res["code"] == 200 and res["data"]['status'] == 1 ):

self.login_ticket = str(res["data"]['account_info']['weblogin_token']) ;

self.account_id= str(res["data"]['account_info']['account_id']);

self.login_uid= str(res["data"]['account_info']['account_id']);

cookies_url = "https://webapi.account.mihoyo.com/Api/cookie_accountinfo_by_loginticket?t=1599809011444&login_ticket="+res["data"]['account_info']['weblogin_token']

headers = {

'Cookie': 'login_uid='+self.login_uid+'; account_id='+self.account_id+'; login_ticket='+self.login_ticket

}

response = session.get(cookies_url, headers=headers)

cookies_res = json.loads(response.text)

self.cookie_token= str(cookies_res["data"]['cookie_info']['cookie_token']);

def gameinfo(self,flag):

url = "https://api-takumi.mihoyo.com/event/e20200828bingo/"+flag

if(flag == 'start'):

res = self.post(url,{})

else:

res = self.get(url)

return res['data']['game_id']

def click(self,game_id):

sum = 0

for i in range(9):

url = "https://api-takumi.mihoyo.com/event/e20200828bingo/next?game_id="+str(game_id)+"&index="+str(i);

res = self.post2(url)

if res["message"] == "OK":

sum +=1

if sum == 9:

print("本輪翻卡完畢")

def saveCookies(self):

t = time.time()

item = {

"login_ticket":self.login_ticket,

"t":t,

"account_id":self.account_id,

"login_uid":self.login_uid,

"cookie_token":self.cookie_token,

}

jsonstr = json.dumps(item,ensure_ascii=False)#轉(zhuǎn)json

try:

f =open("./cookies.json",'r')

f.close()

except IOError:

f = open("./cookies.json",'w')

print("新建了文件cookies.json")

f = open("./cookies.json",'w+',encoding='utf-8')

f.write(jsonstr)

f.close()

print("cookies保存成功")

def readCookies(self):

try:

t = time.time()

f =open("./cookies.json",encoding='UTF-8')

item = json.load(f)

if t-item['t']>3600:

return False

else:

self.login_ticket = item['login_ticket']

self.account_id = item['account_id']

self.login_uid = item['login_uid']

self.cookie_token = item['cookie_token']

return True

f.close()

except IOError:

return False

if __name__ == '__main__':

#主程序

crawl = Crawl()

# 登錄

if crawl.readCookies() == True:

word = input("您在一小時(shí)前登錄過(guò),是否讀取cookies登錄,回車(chē)確認(rèn),輸入n/N進(jìn)行登錄")

if word != "":

print("開(kāi)始登錄————")

mobile = input("請(qǐng)輸入手機(jī)號(hào)碼:")

print("開(kāi)始獲取驗(yàn)證碼————")

print(crawl.getCaptcha(mobile))

captcha = input("請(qǐng)輸入驗(yàn)證碼:")

crawl.login(mobile,captcha)

crawl.saveCookies()

else:

print("開(kāi)始登錄————")

mobile = input("請(qǐng)輸入手機(jī)號(hào)碼:")

print("開(kāi)始獲取驗(yàn)證碼————")

print(crawl.getCaptcha(mobile))

captcha = input("請(qǐng)輸入驗(yàn)證碼:")

crawl.login(mobile,captcha)

crawl.saveCookies()

#分享

homeRes = crawl.home()

nowday_share_cnt = homeRes['data']['nowday_share_cnt']

if nowday_share_cnt == 0:

print("開(kāi)始分享————")

print(crawl.share())

#獲取基本信息

print("獲取基本信息————")

homeRes = crawl.home()

lucky = homeRes['data']['lucky']

chance = homeRes['data']['chance']

print("當(dāng)前幸運(yùn)值:"+str(lucky))

print("可抽卡數(shù):"+str(chance))

word = None

while word != "":

word = input("是否進(jìn)行翻卡,繼續(xù)請(qǐng)輸入回車(chē),退出請(qǐng)直接關(guān)閉")

if chance == 0:

print("您今天的抽卡已經(jīng)到達(dá)上限,請(qǐng)次日再來(lái)")

word = None

while word != "":

word = input("您的今日的翻卡完畢,請(qǐng)輸入回車(chē)關(guān)閉程序")

exit()

print("開(kāi)始翻卡————")

new_round = homeRes['data']['new_round']

for index in range(chance):

print("開(kāi)始第"+str(index+1)+"次翻卡")

if new_round == True:

flag = "start"

game_id = crawl.gameinfo(flag)

crawl.click(game_id)

else:

flag = "game_info"

game_id = crawl.gameinfo(flag)

crawl.click(game_id)

word = None

while word != "":

word = input("您的今日的翻卡完畢,請(qǐng)輸入回車(chē)關(guān)閉程序")

總結(jié)

以上是生活随笔為你收集整理的python抽卡游戏_【python爬虫】原神公测预抽卡活动自动化抽卡脚本(一小时免登陆)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。