add pole emploi module, advanced filters will come later
This commit is contained in:
parent
824e4b56da
commit
f9192b1e6b
6 changed files with 267 additions and 0 deletions
24
modules/popolemploi/__init__.py
Normal file
24
modules/popolemploi/__init__.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from .backend import PopolemploiBackend
|
||||
|
||||
|
||||
__all__ = ['PopolemploiBackend']
|
||||
50
modules/popolemploi/backend.py
Normal file
50
modules/popolemploi/backend.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.capabilities.job import ICapJob
|
||||
|
||||
from .browser import PopolemploiBrowser
|
||||
from .job import PopolemploiJobAdvert
|
||||
|
||||
__all__ = ['PopolemploiBackend']
|
||||
|
||||
|
||||
class PopolemploiBackend(BaseBackend, ICapJob):
|
||||
NAME = 'popolemploi'
|
||||
DESCRIPTION = u'Pole Emploi website'
|
||||
MAINTAINER = u'Bezleputh'
|
||||
EMAIL = 'carton_ben@yahoo.fr'
|
||||
VERSION = '0.g'
|
||||
|
||||
BROWSER = PopolemploiBrowser
|
||||
|
||||
def search_job(self, pattern=None):
|
||||
with self.browser:
|
||||
return self.browser.search_job(pattern)
|
||||
|
||||
def get_job_advert(self, _id, advert=None):
|
||||
with self.browser:
|
||||
return self.browser.get_job_advert(_id, advert)
|
||||
|
||||
def fill_obj(self, advert, fields):
|
||||
self.get_job_advert(advert.id, advert)
|
||||
|
||||
OBJECTS = {PopolemploiJobAdvert: fill_obj}
|
||||
50
modules/popolemploi/browser.py
Normal file
50
modules/popolemploi/browser.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from weboob.tools.browser.decorators import id2url
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
|
||||
from .pages import SearchPage, AdvertPage
|
||||
from .job import PopolemploiJobAdvert
|
||||
|
||||
|
||||
__all__ = ['PopolemploiBrowser']
|
||||
|
||||
|
||||
class PopolemploiBrowser(BaseBrowser):
|
||||
PROTOCOL = 'http'
|
||||
DOMAIN = 'http://www.pole-emploi.fr/accueil/'
|
||||
ENCODING = None
|
||||
|
||||
PAGES = {
|
||||
'http://candidat.pole-emploi.fr/candidat/rechercheoffres/resultats(.*?)': SearchPage,
|
||||
'http://candidat.pole-emploi.fr/candidat/rechercheoffres/detail/(?P<id>.+)': AdvertPage,
|
||||
}
|
||||
|
||||
def search_job(self, pattern=None):
|
||||
self.location('http://offre.pole-emploi.fr/resultat?offresPartenaires=true&libMetier=%s'
|
||||
% pattern.replace(' ', '+'))
|
||||
assert self.is_on_page(SearchPage)
|
||||
return self.page.iter_job_adverts()
|
||||
|
||||
@id2url(PopolemploiJobAdvert.id2url)
|
||||
def get_job_advert(self, url, advert):
|
||||
self.location(url)
|
||||
assert self.is_on_page(AdvertPage)
|
||||
return self.page.get_job_advert(url, advert)
|
||||
26
modules/popolemploi/job.py
Normal file
26
modules/popolemploi/job.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from weboob.capabilities.job import BaseJobAdvert
|
||||
|
||||
|
||||
class PopolemploiJobAdvert(BaseJobAdvert):
|
||||
@classmethod
|
||||
def id2url(cls, _id):
|
||||
return 'http://candidat.pole-emploi.fr/candidat/rechercheoffres/detail/%s' % _id
|
||||
86
modules/popolemploi/pages.py
Normal file
86
modules/popolemploi/pages.py
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
import dateutil.parser
|
||||
|
||||
from .job import PopolemploiJobAdvert
|
||||
|
||||
|
||||
__all__ = ['SearchPage', 'AdvertPage']
|
||||
|
||||
|
||||
class SearchPage(BasePage):
|
||||
def iter_job_adverts(self):
|
||||
rows = self.document.getroot().xpath('//table[@class="definition-table ordered"]/tbody/tr')
|
||||
for row in rows:
|
||||
advert = self.create_job_advert(row)
|
||||
if advert:
|
||||
yield advert
|
||||
|
||||
def create_job_advert(self, row):
|
||||
a = self.parser.select(row, 'td[@headers="offre"]/a', 1, method='xpath')
|
||||
_id = u'%s' % (a.attrib['href'][-7:])
|
||||
if _id:
|
||||
advert = PopolemploiJobAdvert(_id)
|
||||
advert.contract_type = u'%s' % self.parser.select(row, 'td[@headers="contrat"]', 1, method='xpath').text
|
||||
advert.title = u'%s' % a.text_content().strip()
|
||||
society = self.parser.select(row, 'td/div/p/span[@class="company"]', method='xpath')
|
||||
if society:
|
||||
advert.society_name = society[0].text
|
||||
advert.place = u'%s' % self.parser.select(row, 'td[@headers="lieu"]', 1, method='xpath').text_content()
|
||||
date = self.parser.select(row, 'td[@headers="dateEmission"]', 1, method='xpath')
|
||||
advert.publication_date = dateutil.parser.parse(date.text).date()
|
||||
return advert
|
||||
|
||||
|
||||
class AdvertPage(BasePage):
|
||||
def get_job_advert(self, url, advert):
|
||||
content = self.document.getroot().xpath('//div[@class="block-content"]/div')[0]
|
||||
if not advert:
|
||||
_id = self.parser.select(content, 'ul/li/ul/li/div[@class="value"]/span', 1, method='xpath').text
|
||||
advert = PopolemploiJobAdvert(_id)
|
||||
|
||||
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
|
||||
advert.url = url
|
||||
advert.place = u'%s' % self.parser.select(content,
|
||||
'ul/li/div[@class="value"]/ul/li[@itemprop="addressRegion"]',
|
||||
1, method='xpath').text.strip()
|
||||
|
||||
advert.contract_type = u'%s' % self.parser.select(content,
|
||||
'ul/li/div[@class="value"]/span[@itemprop="employmentType"]',
|
||||
1, method='xpath').text.strip()
|
||||
|
||||
advert.experience = u'%s' % self.parser.select(content,
|
||||
'ul/li/div[@class="value"]/span[@itemprop="experienceRequirements"]',
|
||||
1, method='xpath').text.strip()
|
||||
|
||||
advert.formation = u'%s' % self.parser.select(content,
|
||||
'ul/li/div[@class="value"]/span[@itemprop="qualifications"]',
|
||||
1, method='xpath').text.strip()
|
||||
|
||||
advert.pay = u'%s' % self.parser.select(content,
|
||||
'ul/li/div[@class="value"]/span[@itemprop="baseSalary"]',
|
||||
1, method='xpath').text.strip()
|
||||
return advert
|
||||
31
modules/popolemploi/test.py
Normal file
31
modules/popolemploi/test.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2013 Bezleputh
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.test import BackendTest
|
||||
|
||||
|
||||
class PopolemploiTest(BackendTest):
|
||||
BACKEND = 'popolemploi'
|
||||
|
||||
def test_popolemploi(self):
|
||||
l = list(self.backend.search_job('infographiste'))
|
||||
assert len(l)
|
||||
advert = self.backend.get_job_advert(l[0].id, l[0])
|
||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||
Loading…
Add table
Add a link
Reference in a new issue