Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. import datetime
  2.  
  3. import requests
  4. from bs4 import BeautifulSoup
  5.  
  6.  
  7. class EveSession():
  8. __LOGIN_URL = "https://login.eveonline.com/account/logon?ReturnUrl=%2F"
  9. __ACCOUNT_MANAGEMENT_URL = "https://secure.eveonline.com/AccountManMenu.aspx"
  10.  
  11. def __init__(self):
  12. self.session = requests.Session()
  13. self.logged_in = False
  14.  
  15. def login(self, username, password):
  16. self.username = username
  17. self.password = password
  18. login_payload = {
  19. "__RequestVerificationToken": self.__getVerificationToken(),
  20. "UserName": username,
  21. "Password": password,
  22. "RememberMe": 'false'
  23. }
  24. self.session.post(EveSession.__LOGIN_URL, login_payload)
  25.  
  26. def getAccountInformation(self):
  27. account_information = {}
  28. management_soup = BeautifulSoup(self.session.get(EveSession.__ACCOUNT_MANAGEMENT_URL).content, 'html.parser')
  29.  
  30. omega = len(management_soup.find_all("span", {"class": "Active"})) == 1
  31.  
  32. if omega:
  33. time_left_text = list(management_soup.find("div", {"class": "inner subs-payment"}).find_all("p"))[2].text.split("UTC")[0]
  34. time = datetime.datetime.strptime(time_left_text, "%d %B %Y - %H:%M %p ")
  35.  
  36. account_information["Account Expires"] = time
  37. else:
  38. #account_information["Account Expires"] = (datetime.datetime.now() + datetime.timedelta(days=29)).replace(microsecond=0)
  39. account_information["Account Expires"] = "Expired"
  40. return account_information
  41.  
  42.  
  43.  
  44. def __getVerificationToken(self):
  45. login_page = self.session.get(EveSession.__LOGIN_URL).content
  46. token = BeautifulSoup(login_page, 'html.parser').find('input').attrs['value']
  47. return str(token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement