本文整理汇总了Python中weboob.browser.filters.standard.CleanText.split方法的典型用法代码示例。如果您正苦于以下问题:Python CleanText.split方法的具体用法?Python CleanText.split怎么用?Python CleanText.split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.browser.filters.standard.CleanText
的用法示例。
在下文中一共展示了CleanText.split方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: obj_size
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_size(self):
rawsize = CleanText('./div[has-class("poid")]')(self)
rawsize = rawsize.replace(',','.').strip()
nsize = float(rawsize.split()[0])
usize = rawsize.split()[-1].upper().replace('O','B')
size = get_bytes_size(nsize,usize)
return size
示例2: obj_label
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_label(self):
raw_label = CleanText(TableCell('label'))(self)
label = CleanText(TableCell('label')(self)[0].xpath('./br/following-sibling::text()'))(self)
if (label and label.split()[0] != raw_label.split()[0]) or not label:
label = raw_label
return CleanText(TableCell('label')(self)[0].xpath('./noscript'))(self) or label
示例3: obj_details
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_details(self):
details = {}
details["creationDate"] = Date(
Regexp(
CleanText(
'//p[@class="offer-description-notes"]|//p[has-class("darkergrey")]'
),
u'.*Mis en ligne : (\d{2}/\d{2}/\d{4}).*'
),
dayfirst=True
)(self)
honoraires = CleanText(
(
'//div[has-class("offer-price")]/span[has-class("lbl-agencyfees")]'
),
default=None
)(self)
if honoraires:
details["Honoraires"] = (
"{} (TTC, en sus)".format(
honoraires.split(":")[1].strip()
)
)
for li in XPath('//ul[@itemprop="description"]/li')(self):
label = CleanText('./div[has-class("criteria-label")]')(li)
value = CleanText('./div[has-class("criteria-value")]')(li)
details[label] = value
return details
示例4: get_author
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def get_author(self):
try:
author = CleanText('.')(self.get_element_author())
if author.startswith('Par '):
return author.split('Par ', 1)[1]
else:
return author
except AttributeError:
return ''
示例5: next_page
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def next_page(self):
js_datas = CleanText('//div[@id="js-data"]/@data-rest-search-request')(self)
total_page = self.page.browser.get_total_page(js_datas.split("?")[-1])
m = re.match(".*page=(\d?)(?:&.*)?", self.page.url)
if m:
current_page = int(m.group(1))
next_page = current_page + 1
if next_page <= total_page:
return self.page.url.replace("page=%d" % current_page, "page=%d" % next_page)
示例6: check_errors
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def check_errors(self):
# check if user can add new recipient
errors_id = ('popinClientNonEligible', 'popinClientNonEligibleBis')
for error_id in errors_id:
if self.doc.xpath('//script[contains(text(), "showDivJQInfo(\'%s\')")]' % error_id):
msg = CleanText('//div[@id="%s"]//p' % error_id)(self.doc)
# get the first sentence of information message
# beacause the message is too long and contains unnecessary recommendations
raise AddRecipientBankError(message=msg.split('.')[0])
示例7: obj_code
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_code(self):
# We try to get the code from <a> div. If we didn't find code in url,
# we try to find it in the cell text
tablecell = TableCell('label', colspan=True)(self)[0]
# url find try
url = tablecell.xpath('./following-sibling::td[position()=1]/div/a')[0].attrib['href']
code_match = re.search(r'sico=([A-Z0-9]*)', url)
if code_match:
if is_isin_valid(code_match.group(1)):
return code_match.group(1)
# cell text find try
text = CleanText(tablecell.xpath('./following-sibling::td[position()=1]/div')[0])(self)
for code in text.split(' '):
if is_isin_valid(code):
return code
return NotAvailable
示例8: obj_id
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_id(self):
try:
_id = CleanText('.//td/a/@id')(self)
if not _id:
ac_details_page = self.page.browser.open(Link('.//td/a')(self)).page
else:
if '-' in _id:
split = _id.split('-')
ac_details_page = self.page.browser.open('/outil/UWVI/AssuranceVie/accesDetail?ID_CONTRAT=%s&PRODUCTEUR=%s' % (split[0], split[1])).page
else:
ac_details_page = self.page.browser.open('/outil/UWVI/AssuranceVie/accesDetail?ID_CONTRAT=%s' % (_id)).page
return CleanText('(//tr[3])/td[2]')(ac_details_page.doc)
except ServerError:
self.logger.debug("link didn't work, trying with the form instead")
# the above server error can cause the form to fail, so we may have to go back on the accounts list before submitting
self.page.browser.open(self.page.url)
# redirection to lifeinsurances accounts and comeback on Lcl original website
page = self.obj__form().submit().page
account_id = page.get_account_id()
page.come_back()
return account_id
示例9: obj_date
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_date(self):
time = CleanText(u'//span[@id="refresh_time"]')(self)
time = [int(t) for t in time.split(":")]
now = datetime.datetime.now()
now.replace(hour=time[0], minute=time[1])
return now
示例10: get_history
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def get_history(self, account):
# checking if the card is still valid
if self.doc.xpath('//div[@id="errorbox"]'):
return
# adding a time delta because amex have hard time to put the date in a good interval
beginning_date = self.get_beginning_debit_date() - datetime.timedelta(days=360)
end_date = self.get_end_debit_date()
guesser = ChaoticDateGuesser(beginning_date, end_date)
# Since the site doesn't provide the debit_date,
# we just use the date of beginning of the previous period.
# If this date + 1 month is greater than today's date,
# then the transaction is coming
end_of_period = None
previous_date = CleanText('//td[@id="colStatementBalance"]/div[3]', default=None)(self.doc)
if previous_date:
end_of_period = (parse_french_date(' '.join(previous_date.split()[1:4])) + relativedelta(months=1)).date()
else:
previous_date = CleanText('//select[@id="viewPeriod"]/option[@selected]', default=None)(self.doc)
if previous_date:
end_of_period = parse_french_date(' '.join(previous_date.split()[:3])) + relativedelta(days=-1) + relativedelta(months=1)
end_of_period = end_of_period.date()
_id = str(int(account._idforold))
for tr in reversed(self.doc.xpath('//div[@id="txnsSection"]//tbody[@id="tableBody-txnsCard%s"]/tr[@class="tableStandardText"]' % _id)):
cols = tr.findall('td')
t = Transaction()
day, month = CleanText().filter(cols[self.COL_DATE]).split(' ', 1)
day = int(day)
month = self.parse_month(month)
date = guesser.guess_date(day, month)
vdate = None
try:
detail = cols[self.COL_TEXT].xpath('./div[has-class("hiddenROC")]')[0]
except IndexError:
pass
else:
m = re.search(r' (\d{2} \D{3,4})', (' '.join([txt.strip() for txt in detail.itertext()])).strip())
if m:
vday, vmonth = m.group(1).strip().split(' ')
vday = int(vday)
vmonth = self.parse_month(vmonth)
vdate = guesser.guess_date(vday, vmonth)
detail.drop_tree()
raw = (' '.join([txt.strip() for txt in cols[self.COL_TEXT].itertext()])).strip()
credit = CleanText().filter(cols[self.COL_CREDIT])
debit = CleanText().filter(cols[self.COL_DEBIT])
if end_of_period is not None and datetime.date.today() < end_of_period:
t._is_coming = True
else:
t._is_coming = False
t.date = t.rdate = date
t.vdate = vdate
t.raw = re.sub(r'[ ]+', ' ', raw)
t.label = re.sub('(.*?)( \d+)? .*', r'\1', raw).strip()
t.amount = parse_decimal(credit or debit) * (1 if credit else -1)
if t.raw in self.browser.SUMMARY_CARD_LABEL:
t.type = t.TYPE_CARD_SUMMARY
elif t.amount > 0:
t.type = t.TYPE_ORDER
else:
t.date = end_of_period
t.type = t.TYPE_DEFERRED_CARD
yield t
示例11: obj__invest_account_id
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj__invest_account_id(self):
invest_account_id = CleanText(Dict(
'holdingSummaryInformation/0/accountNumber'
))(self)
return invest_account_id.split(' ')[0]
示例12: obj_publication_date
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_publication_date(self):
content = CleanText('./div[2]')(self)
split_date = content.split('|')[0].split('/')
if len(split_date) == 3:
return date(int(split_date[2]) + 2000, int(split_date[1]), int(split_date[0]))
return ''
示例13: obj_id
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_id(self):
acc_id = CleanText(Dict('accountNumber'))(self)
return acc_id.split(' ')[0]
示例14: obj_size
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_size(self):
rawsize = CleanText('//div[@class="accordion"]//tr[th="Taille totale"]/td')(self)
nsize = float(rawsize.split()[0])
usize = rawsize.split()[-1].upper()
size = get_bytes_size(nsize, usize)
return size
示例15: obj_place
# 需要导入模块: from weboob.browser.filters.standard import CleanText [as 别名]
# 或者: from weboob.browser.filters.standard.CleanText import split [as 别名]
def obj_place(self):
content = CleanText('./div[2]')(self)
if len(content.split('|')) > 1:
return content.split('|')[1]
return ''