You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
auto/message/message_check_grassio.py

90 lines
3.1 KiB

import time
import aiohttp
import asyncio
import json
from fake_useragent import UserAgent
from utils.utils_send_gotify import *
goto_url = 'https://app.getgrass.io/'
account_list = [
'jack0210_@hotmail.com:aaaAAA111!!!',
'yujiec0210@gmail.com:aaaAAA111!!!',
'yujieccyj01@hotmail.com:aaaAAA111!!!',
'yujieccyj02@hotmail.com:aaaAAA111!!!',
'yujieccyj03@hotmail.com:aaaAAA111!!!',
'yujieccyj04@hotmail.com:aaaAAA111!!!',
'yujieccyj05@hotmail.com:aaaAAA111!!!',
'yujieccyj06@hotmail.com:aaaAAA111!!!',
'yujieccyj07@hotmail.com:aaaAAA111!!!',
'yujieccyj08@hotmail.com:aaaAAA111!!!',
'yujieccyj09@hotmail.com:aaaAAA111!!!',
'yujieccyj10@hotmail.com:aaaAAA111!!!',
'yujieccyj11@hotmail.com:aaaAAA111!!!'
]
class LoginClient:
def __init__(self, email, password, user_agent):
self.email = email
self.password = password
self.user_agent = user_agent
self.website_headers = {
'authority': 'api.getgrass.io',
'accept': 'application/json, text/plain, */*',
'accept-language': 'uk-UA,uk;q=0.9,en-US;q=0.8,en;q=0.7',
'content-type': 'application/json',
'origin': 'https://app.getgrass.io',
'referer': 'https://app.getgrass.io/',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': self.user_agent,
}
async def login(self, session):
url = 'https://api.getgrass.io/login'
json_data = {
'password': self.password,
'username': self.email,
}
try:
response = await session.post(url, headers=self.website_headers, data=json.dumps(json_data))
response_text = await response.text()
if response.status != 200:
print(f"Login failed: {response_text}")
return None
return await response.json()
except aiohttp.ClientConnectionError as e:
print(f"Connection error occurred: {e}")
return None
except Exception as e:
print(f"An error occurred: {e}")
return None
if __name__ == "__main__":
async def main():
async with aiohttp.ClientSession() as session:
for account in account_list:
email = account.split(':')[0]
password = account.split(':')[1]
user_agent = UserAgent().random
client = LoginClient(email, password, user_agent)
login_result = await client.login(session)
if login_result:
email = login_result['result']['data']['email']
user_id = login_result['result']['data']['userId']
print(f'account: {email}\nuser_id: {user_id}')
else:
print("Login failed.")
asyncio.run(main())