当前位置: 首页>>代码示例>>Python>>正文


Python Auth.autorize方法代码示例

本文整理汇总了Python中auth.Auth.autorize方法的典型用法代码示例。如果您正苦于以下问题:Python Auth.autorize方法的具体用法?Python Auth.autorize怎么用?Python Auth.autorize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在auth.Auth的用法示例。


在下文中一共展示了Auth.autorize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import autorize [as 别名]
class HttpData:
    def load(self, url):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            headers = {"Referer": url}
            response = xbmcup.net.http.get(url, cookies=self.cookie, headers=headers)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if response.status_code == 200:
                if self.auth.check_auth(response.text) == False:
                    self.auth.autorize()
                return response.text
            return None

    def post(self, url, data):
        try:
            data
        except:
            data = {}
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            headers = {"Referer": url}
            response = xbmcup.net.http.post(url, data, cookies=self.cookie, headers=headers)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if response.status_code == 200:
                if self.auth.check_auth(response.text) == False:
                    self.auth.autorize()
                return response.text
            return None

    def ajax(self, url):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            headers = {"X-Requested-With": "XMLHttpRequest", "Referer": SITE_URL}
            response = xbmcup.net.http.get(url, cookies=self.cookie, headers=headers)
            print url
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            return response.text if response.status_code == 200 else None

    def get_movies(self, url, page, classname="main_content_item", nocache=False, search="", itemclassname="item"):
        page = int(page)
        if page > 0:
            url = SITE_URL + "/" + url.strip("/") + "/page/" + str(page + 1)
        else:
            url = SITE_URL + "/" + url.strip("/")
        print url

        if search != "" and page == 0:
            html = self.post(url, {"usersearch": search, "filter": "all"})
        else:
            html = self.load(url)

        # print html.encode('utf-8')

        if not html:
            return None, {"page": {"pagenum": 0, "maxpage": 0}, "data": []}
        result = {"page": {}, "data": []}
        soup = xbmcup.parser.html(self.strip_scripts(html))
        result["page"] = self.get_page(soup)
        center_menu = soup.find("div", class_=classname)
        # print center_menu
        try:
            for div in center_menu.find_all("div", class_=itemclassname):
                if search != "":
                    href = None
                else:
                    href = div.find("h2").find("a")
                try:
                    quality = div.find("span", class_="quality_film_title").get_text().strip()
                except:
                    quality = ""

                dop_information = []
                try:
                    if itemclassname == "item_wrap":
                        year = div.find("a", class_="fast_search").get_text().strip()
                    else:
                        year = div.find("div", class_="smoll_year").get_text().strip()
                    dop_information.append(year)
                except:
                    pass

                try:
                    if itemclassname == "item_wrap":
                        genre = div.find("span", class_="section_item_list").get_text().strip()
                    else:
                        genre = div.find("div", class_="smoll_janr").get_text().strip()
                    dop_information.append(genre)
                except:
#.........这里部分代码省略.........
开发者ID:TITUS123456,项目名称:repository.evgen_dev.xbmc-addons,代码行数:103,代码来源:http.py

示例2: load

# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import autorize [as 别名]
class HttpData:

    def load(self, url):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            response = xbmcup.net.http.get(url, cookies=self.cookie)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None

    def post(self, url, data):
        try:
            data
        except:
            data = {}
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            response = xbmcup.net.http.post(url, data, cookies=self.cookie)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None


    def ajax(self, url, data={}):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            headers = {
                'X-Requested-With' : 'XMLHttpRequest'
            }
            if(len(data) > 0):
                response = xbmcup.net.http.post(url, data, cookies=self.cookie, headers=headers)
            else:
                response = xbmcup.net.http.get(url, cookies=self.cookie, headers=headers)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            return response.text if response.status_code == 200 else None

    def get_movies(self, url, page, idname='dle-content', nocache=False, search="", itemclassname="shortstory"):
        page = int(page)

        if(page > 0 and search == ''):
            url = SITE_URL+"/"+url.strip('/')+"/page/"+str(page+1)
        else:
            url = SITE_URL+"/"+url.strip('/')

        if(search != ''):
            html = self.ajax(url)
        else:
            html = self.load(url)

        print url

        if not html:
            return None, {'page': {'pagenum' : 0, 'maxpage' : 0}, 'data': []}
        result = {'page': {}, 'data': []}
        soup = xbmcup.parser.html(self.strip_scripts(html))
        if(search != ''):
            result['page'] = self.get_page_search(soup)
        else:
            result['page'] = self.get_page(soup)
        if(idname != ''):
            center_menu = soup.find('div', id=idname)
        else:
            center_menu = soup
        try:
            for div in center_menu.find_all('article', class_=itemclassname):
                href = div.find('div', class_='short')#.find('a')

                not_movie = True
                try:
                    not_movie_test = div.find('span', class_='not-movie').get_text()
                except:
                    not_movie = False

                try:
                    quality = div.find('div', class_='rip').find('span', class_='added-info').get_text().strip()
                except:
                    quality = ''

                dop_information = []
                try:
                    year = div.find('div', class_='item year').find('a').get_text().strip()
                    dop_information.append(year)
#.........这里部分代码省略.........
开发者ID:igran,项目名称:repository.evgen_dev.xbmc-addons,代码行数:103,代码来源:http.py

示例3: load

# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import autorize [as 别名]
class HttpData:

    def load(self, url):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            response = xbmcup.net.http.get(url, cookies=self.cookie)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None

    def post(self, url, data):
        try:
            data
        except:
            data = {}
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            response = xbmcup.net.http.post(url, data, cookies=self.cookie)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None


    def ajax(self, url, data={}):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            headers = {
                'X-Requested-With' : 'XMLHttpRequest'
            }
            if(len(data) > 0):
                response = xbmcup.net.http.post(url, data, cookies=self.cookie, headers=headers)
            else:
                response = xbmcup.net.http.get(url, cookies=self.cookie, headers=headers)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            return response.text if response.status_code == 200 else None

    def get_movies(self, url, page, idname='results', nocache=False, search="", itemclassname="results-item-wrap"):
        page = int(page)

        if(page > 0 and search == ''):
            url = SITE_URL+"/"+url.strip('/')+"?page="+str(page+1)
        else:
            url = SITE_URL+"/"+url.strip('/')

        if(search != ''):
            html = self.load(url)
        else:
            html = self.load(url)

        if not html:
            return None, {'page': {'pagenum' : 0, 'maxpage' : 0}, 'data': []}
        result = {'page': {}, 'data': []}
        soup = xbmcup.parser.html(self.strip_scripts(html))
        print soup
        result['page'] = self.get_page(soup)
        if(idname != ''):
            center_menu = soup.find('ul', class_=idname)
        else:
            center_menu = soup

        try:
            for div in center_menu.find_all('li', class_=itemclassname):
                if(itemclassname == 'vlist-item'):
                    href = div.find('a', class_='main-list-link')
                    name = href.find('h3', class_='main-list-title').get_text().strip()

                    try:
                        rating = div.find('span', class_='main-list-rating').get_text().strip()
                    except:
                        rating = 0

                    dop_information = []
                    try:
                        year = div.find('span', class_='main-list-year').get_text().strip()
                        dop_information.append(year)
                    except:
                        pass

                else:
                    href = div.find('a', class_='results-item')

                    dop_information = []
#.........这里部分代码省略.........
开发者ID:TITUS123456,项目名称:repository.evgen_dev.xbmc-addons,代码行数:103,代码来源:http.py

示例4: load

# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import autorize [as 别名]
class HttpData:

    def load(self, url):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            response = xbmcup.net.http.get(url, cookies=self.cookie)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None

    def post(self, url, data):
        try:
            data
        except:
            data = {}
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            response = xbmcup.net.http.post(url, data, cookies=self.cookie)
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None


    def ajax(self, url):
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            headers = {
                'X-Requested-With' : 'XMLHttpRequest'
            }
            response = xbmcup.net.http.get(url, cookies=self.cookie, headers=headers)
            print url
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            return response.text if response.status_code == 200 else None

    def get_movies(self, url, page, classname='main_content_item', nocache=False, search=""):
        page = int(page)
        if(page > 0):
            url = SITE_URL+"/"+url.strip('/')+"/page/"+str(page+1)
        else:
            url = SITE_URL+"/"+url.strip('/')
        print url

        if(search != ''):
            html = self.post(url, {'usersearch' : search})
        else:
            html = self.load(url)

        if not html:
            return None, {'page': {'pagenum' : 0, 'maxpage' : 0}, 'data': []}
        result = {'page': {}, 'data': []}
        soup = xbmcup.parser.html(self.strip_scripts(html))
        result['page'] = self.get_page(soup)
        center_menu = soup.find('div', class_=classname)

        try:
            for div in center_menu.find_all('div', class_='item'):
                href = div.find('h2').find('a')
                try:
                    quality = div.find('span', class_='quality_film_title').get_text().strip()
                except:
                    quality = ''

                dop_information = []
                try:
                    year = div.find('div', class_='smoll_year').get_text().strip()
                    dop_information.append(year)
                except:
                    pass

                try:
                    genre = div.find('div', class_='smoll_janr').get_text().strip()
                    dop_information.append(genre)
                except:
                    pass

                information = ''
                if(len(dop_information) > 0):
                    information = '[COLOR white]['+', '.join(dop_information)+'][/COLOR]'

                posters = div.find('div', class_='preview').find_all('img')
                movieposter = None
                for img in posters:
#.........这里部分代码省略.........
开发者ID:bigdragon1977,项目名称:repository.evgen_dev.xbmc-addons,代码行数:103,代码来源:http.py

示例5: HttpData

# 需要导入模块: from auth import Auth [as 别名]
# 或者: from auth.Auth import autorize [as 别名]
class HttpData(FingerPrint):
    currentFingerPrint = None
    noAuthCookie = {}

    def getFingerPrint(self):
        if self.currentFingerPrint == None:
            return self.getFingerprint()
        return self.currentFingerPrint

    def load(self, url):
        self.currentFingerPrint = self.getFingerPrint()
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()

            reqCookie = self.noAuthCookie if self.cookie==None else self.cookie
            headers = {
                'Referer' : url,
                'User-agent' : self.currentFingerPrint['useragent']
            }
            response = xbmcup.net.http.get(url, cookies=reqCookie, headers=headers)
            self.noAuthCookie = response.cookies
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None

    def post(self, url, data):
        self.currentFingerPrint = self.getFingerPrint()
        try:
            data
        except:
            data = {}
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()
            reqCookie = self.noAuthCookie if self.cookie==None else self.cookie
            headers = {
                'Referer' : url,
                'User-agent' : self.currentFingerPrint['useragent']
            }
            response = xbmcup.net.http.post(url, data, cookies=reqCookie, headers=headers)
            self.noAuthCookie = response.cookies
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                if(self.auth.check_auth(response.text) == False):
                    self.auth.autorize()
                return response.text
            return None

    def ajaxpost(self, url, data):
        try:
            data
        except:
            data = {}
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()

            if(self.cookie != None):
                self.cookie.set('mycook', self.currentFingerPrint['hash'])

            if(self.noAuthCookie != None):
                try:
                    self.noAuthCookie.set('mycook', self.currentFingerPrint['hash'])
                except:
                    pass

            reqCookie = self.noAuthCookie if self.cookie==None else self.cookie
            headers = {
                'Referer' : SITE_URL,
                'X-Requested-With'  : 'XMLHttpRequest',
                'User-agent' : self.currentFingerPrint['useragent']
            }
            response = xbmcup.net.http.post(url, data, cookies=reqCookie, headers=headers)
            #After saving the fingerprint, you do not need to remember cookies
            if(url != SITE_URL+'/film/index/imprint'):
                self.noAuthCookie = response.cookies
        except xbmcup.net.http.exceptions.RequestException:
            print traceback.format_exc()
            return None
        else:
            if(response.status_code == 200):
                return response.text
            return None

    def ajax(self, url):
        self.currentFingerPrint = self.getFingerPrint()
        try:
            self.auth = Auth()
            self.cookie = self.auth.get_cookies()

#.........这里部分代码省略.........
开发者ID:evgen-dev,项目名称:repository.evgen_dev.xbmc-addons,代码行数:103,代码来源:http.py


注:本文中的auth.Auth.autorize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。