diff --git a/modules/senscritique/pages.py b/modules/senscritique/pages.py index bc30a916..9f8bfc78 100644 --- a/modules/senscritique/pages.py +++ b/modules/senscritique/pages.py @@ -23,7 +23,7 @@ from .calendar import SensCritiquenCalendarEvent from datetime import date, datetime, time, timedelta from weboob.tools.browser2.page import HTMLPage, method, ItemElement, ListElement, JsonPage -from weboob.tools.browser2.filters import Filter, Link, CleanText, Regexp +from weboob.tools.browser2.filters import Filter, Link, CleanText, Regexp, Attr __all__ = ['AjaxPage', 'EventPage', 'JsonResumePage'] @@ -117,12 +117,12 @@ class AjaxPage(HTMLPage): class Summary(Filter): def filter(self, el): - title = el[0].xpath("div/img")[0].attrib['alt'].replace('Affiche ', '') - channel_info = el[0].xpath("div/div[@class='elgr-data-channel']") + title = Regexp(Attr('div/img', 'alt'), '^Affiche(.*)')(el[0]) + channel_info = el[0].xpath('div/div[@class="elgr-data-channel"]') if channel_info: - channel = channel_info[0].text.strip() + channel = CleanText('.')(channel_info[0]) else: - channel_info = el[0].xpath('div[@class="elgr-product-data"]/span')[0].attrib['class'] + channel_info = Attr('div[@class="elgr-product-data"]/span', 'class')(el[0]) channel = self.page.CHANNELS_PARAM.get(channel_info) return u'%s - %s' % (title, channel) @@ -136,8 +136,8 @@ class Description(Filter): def filter(self, el): header = el[0].xpath("//div[@class='pvi-hero-product']")[0] - title = header.xpath("div[@class='d-rubric-inner']/h1")[0].text.strip() - year = header.xpath("div[@class='d-rubric-inner']/small")[0].text.strip() + title = CleanText("div[@class='d-rubric-inner']/h1")(header) + year = CleanText("div[@class='d-rubric-inner']/small")(header) _infos = header.xpath("ul[@class='pvi-product-specs']/li") infos = ''