add code
This commit is contained in:
parent
83a5a44ee6
commit
8a77641c47
103
catch-the-fish.py
Normal file
103
catch-the-fish.py
Normal file
@ -0,0 +1,103 @@
|
||||
import requests
|
||||
import time
|
||||
import requests
|
||||
|
||||
base_url = "https://invites.fun/api/users?include&sort&page%5Boffset%5D="
|
||||
|
||||
keyword = "catchthefish-fishes"
|
||||
usernames = []
|
||||
total_count = 0
|
||||
my_catch_count = 0
|
||||
|
||||
cookies = {
|
||||
"flarum_remember": "izvHQwoKddgwYWC9e1dFLfcADCOjMnhl2xIEk2BP",
|
||||
"flarum_session": "sGfH8SLqRdmVU4b9p9IIcIu2LEmL6vt0BtkR4GS9"
|
||||
}
|
||||
|
||||
fish_id=0
|
||||
|
||||
user_value=0
|
||||
|
||||
data = {
|
||||
"discussion_id": None,
|
||||
"post_id": None,
|
||||
"user_id": user_value
|
||||
}
|
||||
headers = {
|
||||
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
|
||||
}
|
||||
|
||||
headers1 = {
|
||||
"Accept": "*/*",
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept-Language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
|
||||
"Connection": "keep-alive",
|
||||
"Content-Length": "2",
|
||||
"Content-Type": "application/json; charset=UTF-8",
|
||||
"Cookie": "flarum_remember=izvHQwoKddgwYWC9e1dFLfcADCOjMnhl2xIEk2BP; flarum_session=cgU39wNNAsVd6JbmaIpHZk7AyetKlOrk17ESRe4x",
|
||||
"Dnt": "1",
|
||||
"Host": "invites.fun",
|
||||
"Origin": "https://invites.fun",
|
||||
"Referer": "https://invites.fun/u/babymaybe",
|
||||
"Sec-Ch-Ua": "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"",
|
||||
"Sec-Ch-Ua-Mobile": "?0",
|
||||
"Sec-Ch-Ua-Platform": "\"Windows\"",
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Site": "same-origin",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
|
||||
"X-Csrf-Token": "OPR3t2ceXu0C24RtYGYEa6LUdkYwYRI0dMgHpE3g"
|
||||
}
|
||||
|
||||
|
||||
for offset in range(0, 2001, 20):
|
||||
url = base_url + str(offset)
|
||||
response = requests.get(url, cookies=cookies, headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
count = response.text.count(keyword)
|
||||
if count > 0:
|
||||
count = count // 2
|
||||
total_count += count
|
||||
index = response.text.find(keyword)
|
||||
start_index = response.text.rfind('"username"', 0, index) + 12
|
||||
end_index = response.text.find('"', start_index)
|
||||
username = response.text[start_index:end_index]
|
||||
usernames.append(username)
|
||||
|
||||
start_index = response.text.find('"id"', index) + 6
|
||||
end_index = response.text.find('"', start_index)
|
||||
fish_id = response.text[start_index:end_index]
|
||||
|
||||
# print("username用户名:", username)
|
||||
# print("fish的id:", fish_id)
|
||||
|
||||
username_index = response.text.rfind('"username"', 0, start_index) + 12
|
||||
username_end_index = response.text.find('"', username_index)
|
||||
username_before_keyword = response.text[username_index:username_end_index]
|
||||
|
||||
id_index = response.text.rfind('"id"', 0, username_index) + 6
|
||||
id_end_index = response.text.find('"', id_index)
|
||||
user_value = response.text[id_index:id_end_index]
|
||||
# print("userid:", user_value)
|
||||
fish_url = f"https://invites.fun/api/catch-the-fish/fishes/{fish_id}/catch"
|
||||
data = {
|
||||
"discussion_id": None,
|
||||
"post_id": None,
|
||||
"user_id": user_value
|
||||
}
|
||||
# print("url:", fish_url)
|
||||
|
||||
response = requests.post(fish_url, json=data, headers=headers1)
|
||||
|
||||
# print(response.status_code) # 打印响应状态码
|
||||
# print(response.json()) # 打印响应内容
|
||||
my_catch_count = response.json()['included'][0]['attributes']['my_catch_count']
|
||||
# print(my_catch_count)
|
||||
|
||||
output = f"当前页面的值: {offset} 已抓到: {total_count}条鱼 累计抓到: {my_catch_count}条鱼"
|
||||
print(output, end="\r", flush=True)
|
||||
|
||||
time.sleep(1) # 延时1秒
|
||||
|
||||
print("抓鱼结束")
|
||||
Loading…
x
Reference in New Issue
Block a user