From 1df366598b83f2dee37fad25998727169e7c9e11 Mon Sep 17 00:00:00 2001 From: Bezleputh Date: Fri, 26 Jul 2013 22:49:16 +0200 Subject: [PATCH] correct bug when there is no society name --- modules/popolemploi/pages.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/popolemploi/pages.py b/modules/popolemploi/pages.py index 62cd3f5b..10d95c4d 100644 --- a/modules/popolemploi/pages.py +++ b/modules/popolemploi/pages.py @@ -58,11 +58,15 @@ class AdvertPage(BasePage): _id = self.parser.select(content, 'ul/li/ul/li/div[@class="value"]/span', 1, method='xpath').text advert = PopolemploiJobAdvert(_id) + print url advert.title = u'%s' % self.parser.select(content, 'h4', 1, method='xpath').text.strip() advert.job_name = u'%s' % self.parser.select(content, 'h4', 1, method='xpath').text.strip() advert.description = u'%s' % self.parser.select(content, 'p[@itemprop="description"]', 1, method='xpath').text - advert.society_name = u'%s' % self.parser.select(content, 'div[@class="vcard"]/p[@class="title"]/span', - 1, method='xpath').text + society_name = self.parser.select(content, 'div[@class="vcard"]/p[@class="title"]/span', method='xpath') + + if society_name: + advert.society_name = u'%s' % society_name[0].text + advert.url = url advert.place = u'%s' % self.parser.select(content, 'ul/li/div[@class="value"]/ul/li[@itemprop="addressRegion"]',