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


Python CleanText.replace方法代码示例

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


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

示例1: obj_size

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_size(self):
     rawsize = CleanText('./td[2]')(self)
     rawsize = rawsize.replace(',','.')
     nsize = float(rawsize.split()[0])
     usize = rawsize.split()[-1].upper()
     size = get_bytes_size(nsize,usize)
     return size
开发者ID:P4ncake,项目名称:weboob,代码行数:9,代码来源:pages.py

示例2: obj_id

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_id(self):
     href = CleanText('./td[2]/a/@href', default=NotAvailable)(self)
     spl = href.replace('.html', '').split('/')
     lid = spl[2]
     aid = spl[3]
     sid = spl[4]
     return '%s|%s|%s' % (lid, aid, sid)
开发者ID:laurentb,项目名称:weboob,代码行数:9,代码来源:pages.py

示例3: obj_GES

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_GES(self):
     greenhouse_value = CleanText(
         '//div[has-class("offer-energy-greenhouseeffect-summary")]//div[has-class("greenhouse-summary")]',
         default=""
     )(self)
     if len(greenhouse_value):
         greenhouse_value = greenhouse_value.replace("GES", "").strip()[0]
     return getattr(ENERGY_CLASS, greenhouse_value, NotAvailable)
开发者ID:P4ncake,项目名称:weboob,代码行数:10,代码来源:pages.py

示例4: obj_DPE

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_DPE(self):
     energy_value = CleanText(
         '//div[has-class("offer-energy-greenhouseeffect-summary")]//div[has-class("energy-summary")]',
         default=""
     )(self)
     if len(energy_value):
         energy_value = energy_value.replace("DPE", "").strip()[0]
     return getattr(ENERGY_CLASS, energy_value, NotAvailable)
开发者ID:P4ncake,项目名称:weboob,代码行数:10,代码来源:pages.py

示例5: condition

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def condition(self):
     title = CleanText('./div/p[@class="lyric-meta-title"]/a', default="")(self)
     content = CleanText('./pre[@class="lyric-body"]')(self)
     return content.replace(title, "").strip() != ""
开发者ID:laurentb,项目名称:weboob,代码行数:6,代码来源:pages.py

示例6: obj_subscriber

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_subscriber(self):
     subscriber = CleanText('//a[has-class("MainNav-item-logged")]')(self)
     subscriber = subscriber.replace('Bonjour', '').strip()
     return subscriber
开发者ID:laurentb,项目名称:weboob,代码行数:6,代码来源:pages.py

示例7: obj_title

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_title(self):
     artist = CleanText('//h1[@id="profile_name"]//a', default=NotAvailable)(self)
     fullhead = CleanText('//h1[@id="profile_name"]', default=NotAvailable)(self)
     return fullhead.replace('by %s' % artist, '')
开发者ID:dasimon,项目名称:weboob,代码行数:6,代码来源:pages.py

示例8: obj_phone

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
 def obj_phone(self):
     phone = CleanText('(//div[has-class("contact-proprietaire-box")]//strong[@class="tel-wrapper"])[1]')(self)
     phone = phone.replace(' ', ', ')
     return phone
开发者ID:P4ncake,项目名称:weboob,代码行数:6,代码来源:pages.py

示例9: iter_accounts

# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import replace [as 别名]
    def iter_accounts(self, next_pages):
        params = self.get_params()

        account = None
        currency = None
        for th in self.doc.xpath('//table[@id="tbl1"]//thead//th'):
            m = re.match('.*\((\w+)\)$', th.text)
            if m and currency is None:
                currency = Account.get_currency(m.group(1))

        if currency is None:
            currency = Account.get_currency(CleanText('//td[@id="tbl1_0_5_Cell"]//span')(self.doc))

        for tr in self.doc.xpath('//table[@id="tbl1"]/tbody/tr'):
            cols = tr.xpath('./td')

            if len(cols) == 1 and CleanText('.')(cols[0]) == 'pas de carte':
                self.logger.debug('there are no cards on this page')
                continue

            id = CleanText(None).filter(cols[self.COL_ID])
            if len(id) > 0:
                if account is not None:
                    yield account
                account = Account()
                account.id = id.replace(' ', '')
                account.type = Account.TYPE_CARD
                account.balance = account.coming = Decimal('0')
                account._next_debit = datetime.date.today()
                account._prev_debit = datetime.date(2000,1,1)
                account.label = u' '.join([CleanText(None).filter(cols[self.COL_TYPE]),
                                           CleanText(None).filter(cols[self.COL_LABEL])])
                account.currency = currency
                account._params = None
                account._invest_params = None
                account._coming_params = params.copy()
                account._coming_params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE'
                account._coming_params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1]
                account._coming_count = len(self.doc.xpath('//table[@id="tbl1"]/tbody/tr/td[5]/span[not(contains(text(), "(1)"))]'))
            elif account is None:
                raise BrokenPageError('Unable to find accounts on cards page')
            else:
                account._params = params.copy()
                account._params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE'
                account._params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1]

            date_col = CleanText(None).filter(cols[self.COL_DATE])
            m = re.search('(\d+)/(\d+)/(\d+)', date_col)
            if not m:
                self.logger.warning('Unable to parse date %r' % date_col)
                continue

            date = datetime.date(*[int(c) for c in m.groups()][::-1])
            if date.year < 100:
                date = date.replace(year=date.year+2000)

            amount = Decimal(FrenchTransaction.clean_amount(CleanText(None).filter(cols[self.COL_AMOUNT])))

            if not date_col.endswith('(1)'):
                # debited
                account.coming += - abs(amount)
                account._next_debit = date
            elif date > account._prev_debit:
                account._prev_balance = - abs(amount)
                account._prev_debit = date

        if account is not None:
            yield account

        # Needed to preserve navigation.
        btn = self.doc.xpath('.//button[span[text()="Retour"]]')
        if len(btn) > 0:
            actions = self.get_button_actions()
            _params = params.copy()
            _params.update(actions[btn[0].attrib['id']])
            self.browser.open('/cyber/internet/ContinueTask.do', data=_params)
开发者ID:laurentb,项目名称:weboob,代码行数:78,代码来源:pages.py


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