[senscritique] improve browser2 adaptation

This commit is contained in:
Bezleputh 2014-03-22 14:54:50 +01:00
commit 007d99faf5

View file

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