[apec] fix drunk developer errors
This commit is contained in:
parent
d10ff48c8e
commit
d21565b292
3 changed files with 28 additions and 56 deletions
|
|
@ -39,7 +39,9 @@ class ApecBrowser(PagesBrowser):
|
||||||
json_ids = URL('/cms/webservices/rechercheOffre/ids', IdsPage)
|
json_ids = URL('/cms/webservices/rechercheOffre/ids', IdsPage)
|
||||||
json_offre = URL('/cms/webservices/offre/public\?numeroOffre=(?P<_id>.*)', OffrePage)
|
json_offre = URL('/cms/webservices/offre/public\?numeroOffre=(?P<_id>.*)', OffrePage)
|
||||||
|
|
||||||
def create_parameters(self, pattern='', fonctions='[]', lieux='[]', secteursActivite='[]', typesContrat='[]', typesConvention='[]', niveauxExperience='[]', salaire_min='', salaire_max='', date_publication='', start=0, range=20):
|
def create_parameters(self, pattern='', fonctions='[]', lieux='[]', secteursActivite='[]', typesContrat='[]',
|
||||||
|
typesConvention='[]', niveauxExperience='[]', salaire_min='', salaire_max='',
|
||||||
|
date_publication='', start=0, range=20):
|
||||||
|
|
||||||
if date_publication:
|
if date_publication:
|
||||||
date_publication = ',"anciennetePublication":%s' % (date_publication)
|
date_publication = ',"anciennetePublication":%s' % (date_publication)
|
||||||
|
|
@ -54,19 +56,23 @@ class ApecBrowser(PagesBrowser):
|
||||||
|
|
||||||
def search_job(self, pattern=None):
|
def search_job(self, pattern=None):
|
||||||
data = self.create_parameters(pattern=pattern)
|
data = self.create_parameters(pattern=pattern)
|
||||||
|
return self.get_job_adverts(data, pattern=pattern)
|
||||||
|
|
||||||
|
def get_job_adverts(self, data, pattern='', lieux='', fonctions='', secteursActivite='', salaire_min='',
|
||||||
|
salaire_max='', typesContrat='', date_publication='', niveauxExperience='', typesConvention=''):
|
||||||
count = self.json_count.go(data=data).get_adverts_number()
|
count = self.json_count.go(data=data).get_adverts_number()
|
||||||
self.start = 0
|
self.start = 0
|
||||||
if count:
|
if count:
|
||||||
ids = self.json_ids.go(data=data).iter_job_adverts(pattern=pattern,
|
ids = self.json_ids.go(data=data).iter_job_adverts(pattern=pattern,
|
||||||
fonctions='[]',
|
fonctions='[%s]' % fonctions,
|
||||||
lieux='[]',
|
lieux='[%s]' % lieux,
|
||||||
secteursActivite='[]',
|
secteursActivite='[%s]' % secteursActivite,
|
||||||
typesContrat='[]',
|
typesContrat='[%s]' % typesContrat,
|
||||||
typesConvention='[]',
|
niveauxExperience='[%s]' % niveauxExperience,
|
||||||
niveauxExperience='[]',
|
typesConvention='[%s]' % typesConvention,
|
||||||
salaire_min='',
|
salaire_min=salaire_min,
|
||||||
salaire_max='',
|
salaire_max=salaire_max,
|
||||||
date_publication='',
|
date_publication=date_publication,
|
||||||
start=self.start,
|
start=self.start,
|
||||||
count=count,
|
count=count,
|
||||||
range=20)
|
range=20)
|
||||||
|
|
@ -94,20 +100,12 @@ class ApecBrowser(PagesBrowser):
|
||||||
salaire_max=salaire_max,
|
salaire_max=salaire_max,
|
||||||
date_publication=limit_date)
|
date_publication=limit_date)
|
||||||
|
|
||||||
count = self.json_count.go(data=data).get_adverts_number()
|
return self.get_job_adverts(data,
|
||||||
self.start
|
fonctions=fonction,
|
||||||
if count:
|
lieux=region,
|
||||||
ids = self.json_ids.go(data=data).iter_job_adverts(pattern='',
|
secteursActivite=secteur,
|
||||||
fonctions='[%s]' % fonction,
|
typesContrat=contrat,
|
||||||
lieux='[%s]' % region,
|
niveauxExperience=level,
|
||||||
secteursActivite='[%s]' % secteur,
|
salaire_min=salaire_min,
|
||||||
typesContrat='[%s]' % contrat,
|
salaire_max=salaire_max,
|
||||||
niveauxExperience='[%s]' % level,
|
date_publication=limit_date)
|
||||||
salaire_min=salaire_min,
|
|
||||||
salaire_max=salaire_max,
|
|
||||||
date_publication=limit_date,
|
|
||||||
start=self.start,
|
|
||||||
count=count,
|
|
||||||
range=20)
|
|
||||||
for _id in ids:
|
|
||||||
yield self.json_offre.go(_id=_id).get_job_advert()
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
# -*- 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 ApecJobAdvert(BaseJobAdvert):
|
|
||||||
@classmethod
|
|
||||||
def id2url(cls, _id):
|
|
||||||
splitted_id = _id.split('/')
|
|
||||||
return 'http://cadres.apec.fr/offres-emploi-cadres/offres-emploi-cadres/0_0_0_%s________%s.html' % (splitted_id[0], splitted_id[1])
|
|
||||||
|
|
@ -19,19 +19,20 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.tools.test import BackendTest
|
from weboob.tools.test import BackendTest
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
class ApecTest(BackendTest):
|
class ApecTest(BackendTest):
|
||||||
MODULE = 'apec'
|
MODULE = 'apec'
|
||||||
|
|
||||||
def test_apec_search(self):
|
def test_apec_search(self):
|
||||||
l = list(self.backend.search_job(u'informaticien'))
|
l = list(itertools.islice(self.backend.search_job(u'informaticien'), 0, 50))
|
||||||
assert len(l)
|
assert len(l)
|
||||||
advert = self.backend.get_job_advert(l[0].id, None)
|
advert = self.backend.get_job_advert(l[0].id, None)
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
||||||
|
|
||||||
def test_apec_advanced_search(self):
|
def test_apec_advanced_search(self):
|
||||||
l = list(self.backend.advanced_search_job())
|
l = list(itertools.islice(self.backend.advanced_search_job(), 0, 50))
|
||||||
assert len(l)
|
assert len(l)
|
||||||
advert = self.backend.get_job_advert(l[0].id, None)
|
advert = self.backend.get_job_advert(l[0].id, None)
|
||||||
self.assertTrue(advert.url, 'URL for announce "%s" not found: %s' % (advert.id, advert.url))
|
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