Commit f60433e3 authored by Bezleputh's avatar Bezleputh Committed by ntome

[lolix] R.I.P.

parent f0b528c7
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see <http://www.gnu.org/licenses/>.
from .module import LolixModule
__all__ = ['LolixModule']
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.browser import PagesBrowser, URL
from .pages import SearchPage, AdvertPage
__all__ = ['LolixBrowser']
class LolixBrowser(PagesBrowser):
BASEURL = 'http://fr.lolix.org'
ENCODING = 'iso-8859-1'
search_page = URL('/search/offre/search.php', SearchPage)
advert_page = URL('/search/offre/offre.php\?id=(?P<id>.+)', AdvertPage)
def advanced_search_job(self, region=0, poste=0, contrat=0, limit_date=0, pattern=None):
data = {
'mode': 'find',
'page': '0',
'posteid': poste,
'contratid': contrat,
'regionid': region,
'limitjour': limit_date
}
return self.search_page.go(data=data).iter_job_adverts(pattern=pattern)
def get_job_advert(self, id, advert):
return self.advert_page.go(id=id).get_job_advert(obj=advert)
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.job import BaseJobAdvert
class LolixJobAdvert(BaseJobAdvert):
@classmethod
def id2url(cls, _id):
return 'http://fr.lolix.org/search/offre/offre.php?id=%s' % _id
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see <http://www.gnu.org/licenses/>.
from collections import OrderedDict
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import Value
from weboob.capabilities.job import CapJob, BaseJobAdvert
from .browser import LolixBrowser
__all__ = ['LolixModule']
class LolixModule(Module, CapJob):
NAME = 'lolix'
DESCRIPTION = u'Lolix French free software employment website'
MAINTAINER = u'Bezleputh'
EMAIL = 'carton_ben@yahoo.fr'
VERSION = '1.6'
LICENSE = 'AGPLv3+'
BROWSER = LolixBrowser
region_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
'0': u'-- Indifférent --',
'100000000': u'-- France entière',
'100100000': u'-- France métropolitaine',
'100100001': u'-- Alsace',
'100100002': u'-- Auvergne',
'100100003': u'-- Aquitaine',
'100100004': u'-- Bourgogne',
'100100005': u'-- Bretagne',
'100100025': u'-- Centre',
'100100027': u'-- Champagne-Ardenne',
'100100030': u'-- Corse',
'100100037': u'-- Franche-Comté',
'100100040': u'-- Ile de France',
'100100044': u'-- Languedoc-Roussillon',
'100100048': u'-- Limousin',
'100100051': u'-- Lorraine',
'100100055': u'-- Midi-Pyrénées',
'100100060': u'-- Nord-Pas-de-Calais',
'100100073': u'-- Normandie',
'100100076': u'-- Pays-de-Loire',
'100100079': u'-- Picardie',
'100100082': u'-- Poitou-Charentes',
'100100085': u'-- Provence Alpes Cote d\'azur',
'100100090': u'-- Rhône Alpes',
'100200000': u'-- DOM et TOM',
'100200001': u'-- Guadeloupe',
'100200002': u'-- Guyane',
'100200003': u'-- Martinique',
'100200004': u'-- Réunion',
'100200005': u'-- Saint-Pierre et Miquelon',
'200000000': u'-- Etranger',
}.items())])
poste_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
'0': u'-- Indifférent --',
'100000000': u'-- Service Technique',
'100005000': u'-- Administrateur base de données',
'100004000': u'-- Admin. Système/Réseaux',
'100004004': u'-- Administrateur système',
'100004002': u'-- Administrateur réseaux',
'100007000': u'-- Analyste',
'100002000': u'-- Chef de projet',
'100002001': u'-- Chef de projet junior',
'100002002': u'-- Chef de projet senior',
'100021000': u'-- Consultant',
'100003000': u'-- Développeur',
'100003001': u'-- Développeur junior',
'100003002': u'-- Développeur senior',
'100009000': u'-- Directeur technique',
'100006000': u'-- Ingénieur d\'étude',
'100011000': u'-- Ingénieur support',
'100012000': u'-- Responsable R & D',
'100010000': u'-- Technicien',
'100010002': u'-- Technicien hotline',
'100010003': u'-- Technicien maintenance',
'100020000': u'-- Webmaster',
'200000000': u'-- Service Commercial',
'200300000': u'-- Commercial',
'200200000': u'-- Directeur commercial',
'200100000': u'-- Technico commercial',
'400000000': u'-- Service Marketing',
'400100000': u'-- Responsable Marketing',
'300000000': u'-- Service qualité',
'300100000': u'-- Assistant qualité',
'300200000': u'-- Responsable qualité',
'2000000': u'-- Fondateur',
'7000000': u'-- Formateur',
'6000000': u'-- Journaliste',
'500100000': u'-- Assistant(e) de direction',
'4000000': u'-- Stagiaire',
'5000000': u'-- Traducteur',
}.items())])
'''
'000000' in order to display description in console question
the rule is : len(key) > 5 or ' ' in key:
'''
contrat_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
'000000': u'-- Indifférent --',
'6': u'Alternance',
'5': u'Apprentissage',
'2': u'CDD',
'1': u'CDI',
'4': u'Freelance',
'3': u'Stage',
}.items())])
limit_date_choices = OrderedDict([(k, u'%s' % (v)) for k, v in sorted({
'2592000': u'30 jours',
'5184000': u'60 jours',
'7776000': u'90 jours',
'0': u'Illimitée',
}.items())])
CONFIG = BackendConfig(Value('region', label=u'Région', choices=region_choices),
Value('poste', label=u'Poste', choices=poste_choices),
Value('contrat', label=u'Contrat', choices=contrat_choices),
Value('limit_date', label=u'Date limite', choices=limit_date_choices))
def search_job(self, pattern=None):
return self.browser.advanced_search_job(pattern=pattern)
def advanced_search_job(self):
for advert in self.browser.advanced_search_job(region=self.config['region'].get(),
poste=self.config['poste'].get(),
contrat=int(self.config['contrat'].get()),
limit_date=self.config['limit_date'].get()):
yield advert
def get_job_advert(self, _id, advert=None):
return self.browser.get_job_advert(_id, advert)
def fill_obj(self, advert, fields):
self.get_job_advert(advert.id, advert)
OBJECTS = {BaseJobAdvert: fill_obj}
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.browser.pages import HTMLPage
from weboob.browser.elements import TableElement, ItemElement, method
from weboob.browser.filters.standard import CleanText, Regexp, Date, Env, BrowserURL, Join, Format
from weboob.browser.filters.html import CleanHTML, TableCell
from weboob.capabilities.job import BaseJobAdvert
class AdvertPage(HTMLPage):
@method
class get_job_advert(ItemElement):
klass = BaseJobAdvert
obj_id = Env('id')
obj_url = BrowserURL('advert_page', id=Env('id'))
obj_society_name = CleanText('//td[@class="Contenu"]/table[4]/tr[1]/td[1]/a')
obj_title = CleanText('//td[@class="Titre15"]')
obj_description = Format('%s\n%s',
Join('\n', u'//td[@class="Contenu"]/table[3]/tr[td/text()="Détails :"]/following-sibling::tr',
textCleaner=CleanHTML),
CleanHTML('//td[@class="Contenu"]/table[2]'))
obj_job_name = CleanText(u'//td[@class="Contenu"]/table[3]/tr/td[text()="Poste :"]/following-sibling::td',
replace=[(u'-- Indifférent --', u'')])
obj_contract_type = CleanText(CleanHTML(u'//td[@class="Contenu"]/table[3]/tr/td[text()="Contrat :"]/following-sibling::td',
default=u''),
replace=[(u'-- Indifférent --', u'')])
obj_pay = CleanText(u'//td[@class="Contenu"]/table[3]/tr/td[contains(text(), "Rémunération")]/following-sibling::td',
default=u'')
obj_place = CleanText(u'//td[@class="Contenu"]/table[3]/tr/td[contains(text(), "Région")]/following-sibling::td',
default=u'',
replace=[(u'-- Indifférent --', u''),
(u'Lieu de travail : ', u'')])
class SearchPage(HTMLPage):
@method
class iter_job_adverts(TableElement):
item_xpath = '//td[@class="Contenu"]/table/tr[position() > 1]'
head_xpath = '//td[@class="Contenu"]/table/tr/td[@class="ListeTitre"]/text()'
col_date = u'Date'
col_societe = u'Société'
col_titre = u'Titre'
col_region = u'Région'
class Item(ItemElement):
klass = BaseJobAdvert
def obj_id(self):
return Regexp(CleanText('./a/@href'),
r'offre.php\?id=(.*)')(TableCell('titre')(self)[0])
obj_publication_date = Date(CleanText(TableCell('date')))
obj_society_name = CleanText(TableCell('societe'))
obj_title = CleanText(TableCell('titre'))
obj_place = CleanText(TableCell('region'))
def validate(self, obj):
if self.env['pattern'] is None or self.env['pattern'].upper() in obj.title.upper():
return obj
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see <http://www.gnu.org/licenses/>.
from weboob.tools.test import BackendTest
from weboob.tools.value import Value
class LolixTest(BackendTest):
MODULE = 'lolix'
def setUp(self):
if not self.is_backend_configured():
self.backend.config['region'] = Value(value='0')
self.backend.config['poste'] = Value(value='0')
self.backend.config['contrat'] = Value(value='0')
self.backend.config['limit_date'] = Value(value='0')
def test_lolix_advanced_search(self):
l = list(self.backend.advanced_search_job())
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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment