• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python compat.urljoin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weboob.tools.compat.urljoin函数的典型用法代码示例。如果您正苦于以下问题:Python urljoin函数的具体用法?Python urljoin怎么用?Python urljoin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: post

    def post(self, contents, max_age):
        form = self.get_form(xpath='//form[@class="well"]')

        password, d = encrypt(b64encode(contents.encode('utf-8')))
        form['content'] = json.dumps(d)
        form['expiration'] = self.AGES[max_age]
        j = form.submit().json()

        assert j['status'] == 'ok'
        return urljoin(urljoin(self.url, form.url), '%s#%s' % (j['paste'], password))
开发者ID:P4ncake,项目名称:weboob,代码行数:10,代码来源:pages.py


示例2: get_accounts_list

    def get_accounts_list(self):
        for table in self.doc.xpath('//div[@class="comptestabl"]/table'):
            try:
                account_type = self.ACCOUNT_TYPES[table.get('summary').lower()]
                if not account_type:
                    account_type = self.ACCOUNT_TYPES[table.xpath('./caption/text()')[0].strip().lower()]
            except (IndexError,KeyError):
                account_type = Account.TYPE_UNKNOWN
            for tr in table.xpath('./tbody/tr'):
                cols = tr.findall('td')

                link = cols[0].find('a')
                if link is None:
                    continue

                a = Account()
                a.type = account_type
                a.id = unicode(re.search('([A-Z\d]{4}[A-Z\d\*]{3}[A-Z\d]{4})', link.attrib['title']).group(1))
                a.label = unicode(link.attrib['title'].replace('%s ' % a.id, ''))
                tmp_balance = CleanText(None).filter(cols[1])
                a.currency = a.get_currency(tmp_balance)
                if not a.currency:
                    a.currency = u'EUR'
                a.balance = Decimal(Transaction.clean_amount(tmp_balance))
                a._has_cards = False
                a.url = urljoin(self.url, link.attrib['href'])
                yield a
开发者ID:P4ncake,项目名称:weboob,代码行数:27,代码来源:pro.py


示例3: iter_advisor

    def iter_advisor(self):
        if not self.advisor.is_here():
            self.location(self.advisor_url.format(self.sag))

        # it looks like we have an advisor only on cmds
        if "ca-cmds" in self.first_domain:
            perimetre, agence = self.page.get_codeperimetre().split('-')
            publickey = self.location(urljoin('https://' + self.first_domain, '/Vitrine/jsp/CMDS/b.js')).page.get_publickey()
            self.location(urljoin('https://' + self.first_domain.replace("www.ca", "www.credit-agricole"),
                                  "vitrine/tracking/t/%s-%s.html" % (hashlib.sha1(perimetre + publickey).hexdigest(),
                                                                     agence)))
            yield self.page.get_advisor()
        # for other we take numbers
        else:
            for adv in self.page.iter_numbers():
                yield adv
开发者ID:laurentb,项目名称:weboob,代码行数:16,代码来源:browser.py


示例4: absurl

 def absurl(self, uri, base=None):
     # FIXME this is copy-pasta from DomainBrowser
     if not base:
         base = self.url
     if base is None or base is True:
         base = self.BASEURL
     return urljoin(base, uri)
开发者ID:laurentb,项目名称:weboob,代码行数:7,代码来源:selenium.py


示例5: obj_photos

 def obj_photos(self):
     photos = []
     for img in XPath('//div[has-class("carousel-content")]//img/@src')(self):
         url = u'%s' % img.replace('75x75', '800x600')
         url = urljoin(self.page.url, url)  # Ensure URL is absolute
         photos.append(HousingPhoto(url))
     return photos
开发者ID:P4ncake,项目名称:weboob,代码行数:7,代码来源:pages.py


示例6: url2page

 def url2page(self, page):
     baseurl = self.PROTOCOL + '://' + self.DOMAIN + self.BASEPATH
     m = re.match('^' + urljoin(baseurl, 'wiki/(.+)$'), page)
     if m:
         return m.group(1)
     else:
         return page
开发者ID:laurentb,项目名称:weboob,代码行数:7,代码来源:browser.py


示例7: obj_url

 def obj_url(self):
     try:
         return urljoin(
             self.page.browser.BASEURL,
             Link('./td[8]/a[1]')(self)
         )
     except XPathNotFound:
         return NotAvailable
开发者ID:laurentb,项目名称:weboob,代码行数:8,代码来源:pages.py


示例8: obj_url

 def obj_url(self):
     url = Link(u'./a', default=NotAvailable)(self)
     if not url:
         url = Regexp(Attr(u'.//span', 'onclick', default=''), r'\'(https.*)\'', default=NotAvailable)(self)
     if url:
         if 'CreditRenouvelable' in url:
             url = Link(u'.//a[contains(text(), "espace de gestion crédit renouvelable")]')(self.el)
         return urljoin(self.page.url, url)
     return url
开发者ID:laurentb,项目名称:weboob,代码行数:9,代码来源:accountlist.py


示例9: next_page

        def next_page(self):
            pager = self.page.doc.xpath('//div[@class="pager"]')
            if pager:  # more than one page if only enough transactions
                assert len(pager) == 1

                next_links = pager[0].xpath('./span/following-sibling::a[@class="page"]')
                if next_links:
                    url_next_page = Link('.')(next_links[0])
                    url_next_page = urljoin(self.page.url, url_next_page)
                    return self.page.browser.build_request(url_next_page)
开发者ID:laurentb,项目名称:weboob,代码行数:10,代码来源:pages.py


示例10: download_document_pdf

    def download_document_pdf(self, document):
        if not isinstance(document, Document):
            document = self.get_document(document)
        if document.url is NotAvailable:
            return
        if document.format == 'pdf':
            return self.browser.open(document.url).content

        url = urljoin(self.browser.BASEURL, document.url)
        return html_to_pdf(self.browser, url=url)
开发者ID:laurentb,项目名称:weboob,代码行数:10,代码来源:module.py


示例11: iter_accounts

 def iter_accounts(self):
     self.accounts.stay_or_go()
     # sometimes when the user has messages, accounts's page will redirect
     # to the message page and the user will have to click "ok" to access his accounts
     # this will happen as long as the messages aren't deleted.
     # In this case, accounts may be reached through a different link (in the "ok" button)
     acc_link = self.page.get_acc_link()
     if acc_link:
         self.location(urljoin(self.BASEURL, acc_link))
     return self.page.iter_accounts()
开发者ID:laurentb,项目名称:weboob,代码行数:10,代码来源:browser.py


示例12: iter_documents

 def iter_documents(self, subid):
     for d in self.doc['data']['items']:
         doc = Document()
         doc.id = '%s_%s' % (subid, d['id'])
         doc._docid = d['id']
         doc.label = d['import']['name']
         doc.date = parse_date(d['import']['endDate'])
         doc.url = urljoin(self.url, '/pagga/download/%s' % doc._docid)
         doc.type = DocumentTypes.BILL
         doc.format = 'pdf'
         yield doc
开发者ID:laurentb,项目名称:weboob,代码行数:11,代码来源:pages.py


示例13: post

 def post(self, paste, max_age=0):
     bin = b64decode(paste.contents)
     name = paste.title or 'file' # filename is mandatory
     filefield = {'file': (name, BytesIO(bin))}
     params = {'format': 'json'}
     if max_age:
         params['delete-day'] = int(math.ceil(max_age / 86400.))
     self.location('/', data=params, files=filefield)
     assert self.upload_page.is_here()
     info = self.page.fetch_info()
     paste.id = urljoin(self.base_url, info['short'])
开发者ID:P4ncake,项目名称:weboob,代码行数:11,代码来源:browser.py


示例14: handle_refresh

    def handle_refresh(self):
        if self.REFRESH_MAX is None:
            return

        for refresh in self.doc.xpath('//head/meta[lower-case(@http-equiv)="refresh"]'):
            m = self.browser.REFRESH_RE.match(refresh.get('content', ''))
            if not m:
                continue
            url = urljoin(self.url, m.groupdict().get('url', None))
            sleep = float(m.groupdict()['sleep'])

            if sleep <= self.REFRESH_MAX:
                self.logger.info('Redirecting to %s', url)
                self.browser.location(url)
                break
            else:
                self.logger.debug('Do not refresh to %s because %s > REFRESH_MAX(%s)' % (url, sleep, self.REFRESH_MAX))
开发者ID:laurentb,项目名称:weboob,代码行数:17,代码来源:pages.py


示例15: iter_documents

 def iter_documents(self, sub):
     elts = self.doc.xpath('//li[@class="rowdate"]')
     for elt in elts:
         try:
             elt.xpath('.//a[contains(@id,"lienPDFReleve")]')[0]
         except IndexError:
            continue
         date_str = elt.xpath('.//span[contains(@id,"moisEnCours")]')[0].text
         month_str = date_str.split()[0]
         date = datetime.strptime(re.sub(month_str, str(FRENCH_MONTHS.index(month_str) + 1), date_str), "%m %Y").date()
         bil = Bill()
         bil.id = sub._id + "." + date.strftime("%Y%m")
         bil.date = date
         bil.format = u'pdf'
         bil.type = u'bill'
         bil.label = u'' + date.strftime("%Y%m%d")
         bil.url = urljoin(self.url, '/PortailAS/PDFServletReleveMensuel.dopdf?PDF.moisRecherche=%s' % date.strftime("%m%Y"))
         yield bil
开发者ID:P4ncake,项目名称:weboob,代码行数:18,代码来源:pages.py


示例16: get_code

    def get_code(self):
        # Codes (AMF / ISIN) are available after a click on a tab
        characteristics_url = urljoin(self.url, Attr(u'//a[contains(text(), "Caractéristiques")]', 'data-href', default=None)(self.doc))
        if characteristics_url is not None:
            detail_page = self.browser.open(characteristics_url).page

            # We prefer to return an ISIN code by default
            code_isin = detail_page.get_code_isin()
            if code_isin is not None:
                self.CODE_TYPE = Investment.CODE_TYPE_ISIN
                return code_isin

            # But if it's unavailable we can fallback to an AMF code
            code_amf = detail_page.get_code_amf()
            if code_amf is not None:
                self.CODE_TYPE = Investment.CODE_TYPE_AMF
                return code_amf

        return NotAvailable
开发者ID:laurentb,项目名称:weboob,代码行数:19,代码来源:pages.py


示例17: fill_video_url

    def fill_video_url(self, video):
        self._setup_session(self.PROFILE)
        try:
            video = self.video_url.open(_id=video.id).fill_url(obj=video)
            if self.method == u'hls':
                streams = []
                for item in self.read_url(video.url):
                    item = item.decode('ascii')
                    if not item.startswith('#') and item.strip():
                        streams.append(item)

                if streams:
                    streams.reverse()
                    url = streams[self.quality] if self.quality < len(streams) else streams[0]
                    video.url = urljoin(video.url, url)
                else:
                    video.url = NotAvailable
            return video
        except HTTPNotFound:
            return video
开发者ID:P4ncake,项目名称:weboob,代码行数:20,代码来源:browser.py


示例18: get_account

    def get_account(self):
        for div in self.doc.xpath('.//div[@id="card-details"]'):
            a = Account()
            a.id = CleanText().filter(div.xpath('.//span[@class="acc-num"]'))
            a.label = CleanText().filter(div.xpath('.//span[@class="card-desc"]'))
            a.type = Account.TYPE_CARD
            balance = CleanText().filter(div.xpath('.//span[@class="balance-data"]'))
            if balance in (u'Indisponible', u'Indisponible Facturation en cours', ''):
                a.balance = NotAvailable
            else:
                a.currency = a.get_currency(balance)
                a.balance = - abs(parse_decimal(balance))

            # Cancel card don't have a link to watch history
            link = self.doc.xpath('.//div[@class="wide-bar"]/h3/a')
            if len(link) == 1:
                a.url = urljoin(self.url, link[0].attrib['href'])
            else:
                a.url = None

            return a
开发者ID:P4ncake,项目名称:weboob,代码行数:21,代码来源:base.py


示例19: absurl

    def absurl(self, uri, base=None):
        """
        Get the absolute URL, relative to a base URL.
        If base is None, it will try to use the current URL.
        If there is no current URL, it will try to use BASEURL.

        If base is False, it will always try to use the current URL.
        If base is True, it will always try to use BASEURL.

        :param uri: URI to make absolute. It can be already absolute.
        :type uri: str

        :param base: Base absolute URL.
        :type base: str or None or False or True

        :rtype: str
        """
        if not base:
            base = self.url
        if base is None or base is True:
            base = self.BASEURL
        return urljoin(base, uri)
开发者ID:P4ncake,项目名称:weboob,代码行数:22,代码来源:browsers.py


示例20: do_login


#.........这里部分代码省略.........
        # The website crash sometime when the module is not on caissedepargne (on linebourse, for exemple).
        # The module think is not connected anymore, so we go to the home logged page. If there are no error
        # that mean we are already logged and now, on the good website

        except ValueError:
            self.home.go()
            if self.home.is_here():
                return
            # If that not the case, that's an other error that we have to correct
            raise

        data = connection.get_response()

        if data is None:
            raise BrowserIncorrectPassword()

        accounts_types = data.get('account', [])
        if not self.nuser and 'WE' not in accounts_types:
            raise BrowserIncorrectPassword("Utilisez Caisse d'Épargne Professionnels et renseignez votre nuser pour connecter vos comptes sur l'epace Professionels ou Entreprises.")

        if len(accounts_types) > 1:
            # Additional request when there is more than one connection type
            # to "choose" from the list of connection types
            self.multi_type = True

            if self.inexttype < len(accounts_types):
                if accounts_types[self.inexttype] == 'EU' and not self.nuser:
                    # when EU is present and not alone, it tends to come first
                    # if nuser is unset though, user probably doesn't want 'EU'
                    self.inexttype += 1

                self.typeAccount = accounts_types[self.inexttype]
            else:
                assert False, 'should have logged in with at least one connection type'
            self.inexttype += 1

            data = self.account_login.go(login=self.username, accountType=self.typeAccount).get_response()

        assert data is not None

        if data.get('authMode', '') == 'redirect':  # the connection type EU could also be used as a criteria
            raise SiteSwitch('cenet')

        typeAccount = data['account'][0]

        if self.multi_type:
            assert typeAccount == self.typeAccount

        id_token_clavier = data['keyboard']['Id']
        vk = CaissedepargneKeyboard(data['keyboard']['ImageClavier'], data['keyboard']['Num']['string'])
        newCodeConf = vk.get_string_code(self.password)

        playload = {
            'idTokenClavier': id_token_clavier,
            'newCodeConf': newCodeConf,
            'auth_mode': 'ajax',
            'nuusager': self.nuser.encode('utf-8'),
            'codconf': '',  # must be present though empty
            'typeAccount': typeAccount,
            'step': 'authentification',
            'ctx': 'typsrv={}'.format(typeAccount),
            'clavierSecurise': '1',
            'nuabbd': self.username
        }

        try:
            res = self.location(data['url'], params=playload)
        except ValueError:
            raise BrowserUnavailable()
        if not res.page:
            raise BrowserUnavailable()

        response = res.page.get_response()

        assert response is not None

        if response['error'] == 'Veuillez changer votre mot de passe':
            raise BrowserPasswordExpired(response['error'])

        if not response['action']:
            # the only possible way to log in w/o nuser is on WE. if we're here no need to go further.
            if not self.nuser and self.typeAccount == 'WE':
                raise BrowserIncorrectPassword(response['error'])

            # we tested all, next iteration will throw the assertion
            if self.inexttype == len(accounts_types) and 'Temporairement votre abonnement est bloqué' in response['error']:
                raise ActionNeeded(response['error'])

            if self.multi_type:
                # try to log in with the next connection type's value
                self.do_login()
                return
            raise BrowserIncorrectPassword(response['error'])

        self.BASEURL = urljoin(data['url'], '/')

        try:
            self.home.go()
        except BrowserHTTPNotFound:
            raise BrowserIncorrectPassword()
开发者ID:laurentb,项目名称:weboob,代码行数:101,代码来源:browser.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python date.parse_french_date函数代码示例发布时间:2022-05-26
下一篇:
Python compat.unicode函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap