get_grassio_user_id.py 3.0 KB

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