コード例 #1
0
ファイル: account.py プロジェクト: EyeOfPython/EvilTravianBot
 def loadup(self):
     """
     Loads cookies, Logins, 
     Loads all villages, events and the hero.
     """
     self.load_db()
     self.load_cookie()
     
     doc_resources = self.request_GET("/dorf1.php")
     if not len(reader.read_resource_fields(doc_resources)):
         self.clear_cookie()
         doc_resources = self.login(doc_login = doc_resources)
         self.save_cookie()
         
         if not len(reader.read_resource_fields(doc_resources)):
             logger.log_error("login failed", "The login failed")
     else:
         self.ajax_token = reader.read_ajax_token(doc_resources)
     
     village = self.request_village(None, doc_resources)
     
     other_villages = self.villages.keys() ^ { village.village_id } # all villages except the active
     
     self.request_villages(other_villages)
     self.request_hero()
     
     self.production_boost = reader.read_production_boost(doc_resources)
コード例 #2
0
ファイル: account.py プロジェクト: EyeOfPython/EvilTravianBot
    def login(self, doc_login = None):
        logger.log_info("login", "logging in...")
        self.clear_cookie()
        doc = doc_login or self.request_GET("/dorf1.php")

        # retrieve current login POST data
        params = {}
        for inpt in doc.find("form[name=login] input"):
            name = inpt.attr('name')
            value = None
            if inpt._is("[value]"):
                value = inpt.attr('value')
            params[name] = value

        # alter it
        params['name'] = self.user_name
        params['password'] = self.password
        params['lowRes'] = '1'
        params['s1'] = 'Einloggen'
        params['w'] = '1920:1080'

        # perform login and return village overview
        doc = self.request_POST("/dorf1.php", params)
        self.ajax_token = reader.read_ajax_token(doc)
        return doc