2023-05-24 20:19:57 -07:00
|
|
|
|
import time
|
|
|
|
|
|
import requests
|
2023-05-25 00:52:12 -07:00
|
|
|
|
import sys
|
2023-05-24 20:19:57 -07:00
|
|
|
|
|
|
|
|
|
|
base_url = "https://invites.fun/api/users?include&sort&page%5Boffset%5D="
|
|
|
|
|
|
|
|
|
|
|
|
keyword = "catchthefish-fishes"
|
|
|
|
|
|
usernames = []
|
|
|
|
|
|
total_count = 0
|
|
|
|
|
|
my_catch_count = 0
|
|
|
|
|
|
|
2023-05-25 00:52:12 -07:00
|
|
|
|
flarum_remember = "izvHQwoKddgwYWC9e1dFLfcADCOjMnhl2xIEk2BP"
|
2023-05-25 18:00:39 -07:00
|
|
|
|
flarum_session = "Ue1XwF5tYIAJO2FcY7cDu3KtbsB5Mzv47GIJOmyY"
|
|
|
|
|
|
X_Csrf_Token = "PnU3bv9gJn8Azv6oqnJvaHH3V7zrGt4RiVyULzGZ"
|
2023-05-25 00:52:12 -07:00
|
|
|
|
|
2023-05-24 20:19:57 -07:00
|
|
|
|
cookies = {
|
2023-05-25 00:52:12 -07:00
|
|
|
|
# "flarum_remember": "izvHQwoKddgwYWC9e1dFLfcADCOjMnhl2xIEk2BP",
|
|
|
|
|
|
# "flarum_session": "sGfH8SLqRdmVU4b9p9IIcIu2LEmL6vt0BtkR4GS9"
|
|
|
|
|
|
"flarum_remember": f"{flarum_remember}",
|
|
|
|
|
|
"flarum_session": f"{flarum_session}"
|
2023-05-24 20:19:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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",
|
2023-05-25 00:52:12 -07:00
|
|
|
|
"Cookie": f"flarum_remember={flarum_remember}; flarum_session={flarum_session}",
|
|
|
|
|
|
# "Cookie": "flarum_remember=izvHQwoKddgwYWC9e1dFLfcADCOjMnhl2xIEk2BP; flarum_session=cgU39wNNAsVd6JbmaIpHZk7AyetKlOrk17ESRe4x",
|
2023-05-24 20:19:57 -07:00
|
|
|
|
"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",
|
2023-05-25 18:00:39 -07:00
|
|
|
|
"X-Csrf-Token": f"{X_Csrf_Token}"
|
2023-05-24 20:19:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-25 18:00:39 -07:00
|
|
|
|
def input_cookies():
|
|
|
|
|
|
global cookies, headers1
|
|
|
|
|
|
|
|
|
|
|
|
flarum_remember = input("请输入flarum_remember的值:")
|
|
|
|
|
|
flarum_session = input("请输入flarum_session的值:")
|
|
|
|
|
|
csrf_token = input("请输入X-Csrf-Token的值:")
|
|
|
|
|
|
|
|
|
|
|
|
cookies["flarum_remember"] = flarum_remember
|
|
|
|
|
|
cookies["flarum_session"] = flarum_session
|
|
|
|
|
|
headers1["X-Csrf-Token"] = csrf_token
|
2023-05-24 20:19:57 -07:00
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
2023-05-25 00:52:12 -07:00
|
|
|
|
if response.status_code != 200:
|
2023-05-25 18:00:39 -07:00
|
|
|
|
print("Cookies过期,请重新输入")
|
|
|
|
|
|
input_cookies()
|
|
|
|
|
|
response = requests.post(fish_url, json=data, headers=headers1)
|
|
|
|
|
|
|
|
|
|
|
|
if response.status_code != 200:
|
|
|
|
|
|
print("重新输入的Cookies无效,请检查输入是否正确")
|
|
|
|
|
|
sys.exit()
|
2023-05-25 00:52:12 -07:00
|
|
|
|
|
|
|
|
|
|
# print(response.status_code) # 打印响应状态码
|
|
|
|
|
|
# print(response.json()) # 打印响应内容
|
|
|
|
|
|
|
|
|
|
|
|
response_data = response.json()
|
|
|
|
|
|
my_catch_count = response_data['included'][0]['attributes']['my_catch_count']
|
2023-05-24 20:19:57 -07:00
|
|
|
|
# print(my_catch_count)
|
|
|
|
|
|
|
|
|
|
|
|
output = f"当前页面的值: {offset} 已抓到: {total_count}条鱼 累计抓到: {my_catch_count}条鱼"
|
|
|
|
|
|
print(output, end="\r", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
time.sleep(1) # 延时1秒
|
2023-05-25 00:52:12 -07:00
|
|
|
|
print(" ", end="\r", flush=True)
|
|
|
|
|
|
print(f"抓鱼结束 这次抓到:{total_count}条鱼 累计抓到: {my_catch_count}条鱼")
|