Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.41 KB | None | 0 0
  1. class Account:
  2.     def getToken(self):
  3.         url = "https://www.darkorbit.com/"
  4.         r = requests.get(url, verify=False)
  5.         tree = html.fromstring(r.content)
  6.         tokenPath = tree.xpath("//form[@name='bgcdw_login_form']/@action")
  7.         self.token = after(tokenPath[0], "token=")
  8.  
  9.     def login(self, user, passs, file):
  10.         self.username = user
  11.         self.password = passs
  12.         self.file = file
  13.         loginData = {'username': user, 'password': passs}
  14.         loginURL = "https://sas.bpsecure.com/Sas/Authentication/Bigpoint?authUser=22&token=" + self.token
  15.         d = requests.post(loginURL, data=loginData, verify=False)
  16.         self.server = between(d.url, "://", ".dark")
  17.         if "darkorbit.com/indexInternal.es?" in d.url:
  18.             self.cookies = d.cookies
  19.             self.startContent = d.content
  20.             return "success"
  21.         else:
  22.             print('Account ' + str(self.file) + ' failed to login.')
  23.     def getName(self):
  24.          tree = html.fromstring(self.startContent)
  25.          name = tree.xpath('//*[@id="userInfoSheet"]/div[1]/text()')
  26.          self.name = name[1].strip()
  27.     def getLoginBonus(self):
  28.         bonusUrl = 'https://'+self.server+'.darkorbit.com/flashAPI/dailyLogin.php?doBook=1'
  29.         c = requests.post(bonusUrl, cookies = self.cookies, verify=False)
  30.         if 'success' and 'true' in c.content.decode():
  31.             print('Login bonus collected on Account' + str(self.file))
  32.         else:
  33.             print('Login Bonus was already collected on Account' + str(self.file))
  34.        
  35.  
  36.     def getInfo(self):
  37.         rankURL = "https://"+self.server+".darkorbit.com/indexInternal.es?action=internalHallofFame&view=dailyRank&lang=en"
  38.         c = requests.get(rankURL, cookies = self.cookies, verify=False)
  39.         tree = html.fromstring(c.content)
  40.         accInfo = tree.xpath('//tr/td[@class="hof_units_amount"]/text()')
  41.         self.xp = accInfo[0]
  42.         self.honor = accInfo[1]
  43.         self.level = accInfo[3]
  44.         self.rankpoints =  accInfo[-1]
  45.         self.uid = tree.xpath('//*[@id="header_top_id"]/div/span/text()')
  46.         self.rank = tree.xpath('//*[@id="hof_content"]/div[1]/strong/text()')[0]
  47.         xpLevel = between(c.text, "header_ttips['exp']     =", """;
  48.        header_ttips['hnr']""")
  49.         rpLevel = tree.xpath('//*[@id="hof_daily_wrapper"]/p[2]/text()')
  50.         self.xpToNextLevel = clearIntFromString(xpLevel)
  51.         self.rpToNextRank = clearIntFromString(rpLevel)
  52.         self.uridium = self.inventory['data']['money']['uridium']
  53.         self.credits = self.inventory['data']['money']['credits']
  54.     def getGateInfo(self):
  55.         self.allGates = []
  56.         gateUrl = 'https://'+self.server+'.darkorbit.com/flashinput/galaxyGates.php?userID='+self.uid[0]+'&action=init&sid='+self.cookies['dosid']
  57.         b = requests.post(gateUrl, cookies=self.cookies)
  58.         self.gateInfo = b.content.decode()
  59.         gateInfo = untangle.parse(self.gateInfo)
  60.         z = 0
  61.         self.gateEnergy = gateInfo.jumpgate.samples.cdata
  62.         while z < 20:
  63.             try:
  64.                 total = gateInfo.jumpgate.gates.gate[z]['total']
  65.                 current = gateInfo.jumpgate.gates.gate[z]['current']
  66.                 prepared = gateInfo.jumpgate.gates.gate[z]['prepared']
  67.                 self.allGates.append(gates(gateList[z], total, current, prepared))
  68.                 z += 1
  69.             except IndexError:
  70.                 return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement