message_check_grassio.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import time
  2. import aiohttp
  3. import asyncio
  4. import json
  5. from fake_useragent import UserAgent
  6. from utils.utils_send_gotify import *
  7. goto_url = 'https://app.getgrass.io/'
  8. account_list = [
  9. 'jack0210_@hotmail.com:aaaAAA111!!!',
  10. 'yujiec0210@gmail.com:aaaAAA111!!!',
  11. 'yujieccyj01@hotmail.com:aaaAAA111!!!',
  12. 'yujieccyj02@hotmail.com:aaaAAA111!!!',
  13. 'yujieccyj03@hotmail.com:aaaAAA111!!!',
  14. 'yujieccyj04@hotmail.com:aaaAAA111!!!',
  15. 'yujieccyj05@hotmail.com:aaaAAA111!!!',
  16. 'yujieccyj06@hotmail.com:aaaAAA111!!!',
  17. 'yujieccyj07@hotmail.com:aaaAAA111!!!',
  18. 'yujieccyj08@hotmail.com:aaaAAA111!!!',
  19. 'yujieccyj09@hotmail.com:aaaAAA111!!!',
  20. 'yujieccyj10@hotmail.com:aaaAAA111!!!',
  21. 'yujieccyj11@hotmail.com:aaaAAA111!!!'
  22. ]
  23. class LoginClient:
  24. def __init__(self, email, password, user_agent):
  25. self.email = email
  26. self.password = password
  27. self.user_agent = user_agent
  28. self.website_headers = {
  29. 'authority': 'api.getgrass.io',
  30. 'accept': 'application/json, text/plain, */*',
  31. 'accept-language': 'uk-UA,uk;q=0.9,en-US;q=0.8,en;q=0.7',
  32. 'content-type': 'application/json',
  33. 'origin': 'https://app.getgrass.io',
  34. 'referer': 'https://app.getgrass.io/',
  35. 'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
  36. 'sec-ch-ua-mobile': '?0',
  37. 'sec-ch-ua-platform': '"Windows"',
  38. 'sec-fetch-dest': 'empty',
  39. 'sec-fetch-mode': 'cors',
  40. 'sec-fetch-site': 'same-site',
  41. 'user-agent': self.user_agent,
  42. }
  43. async def login(self, session):
  44. url = 'https://api.getgrass.io/login'
  45. json_data = {
  46. 'password': self.password,
  47. 'username': self.email,
  48. }
  49. try:
  50. response = await session.post(url, headers=self.website_headers, data=json.dumps(json_data))
  51. response_text = await response.text()
  52. if response.status != 200:
  53. print(f"Login failed: {response_text}")
  54. return None
  55. return await response.json()
  56. except aiohttp.ClientConnectionError as e:
  57. print(f"Connection error occurred: {e}")
  58. return None
  59. except Exception as e:
  60. print(f"An error occurred: {e}")
  61. return None
  62. if __name__ == "__main__":
  63. async def main():
  64. async with aiohttp.ClientSession() as session:
  65. for account in account_list:
  66. email = account.split(':')[0]
  67. password = account.split(':')[1]
  68. user_agent = UserAgent().random
  69. client = LoginClient(email, password, user_agent)
  70. login_result = await client.login(session)
  71. if login_result:
  72. email = login_result['result']['data']['email']
  73. user_id = login_result['result']['data']['userId']
  74. print(f'account: {email}\nuser_id: {user_id}')
  75. else:
  76. print("Login failed.")
  77. asyncio.run(main())