From 6a4c244ff1a855d1a15e1a8b75db2e2f0a778716 Mon Sep 17 00:00:00 2001 From: Ludovic LANGE Date: Sun, 3 Jan 2021 22:53:42 +0100 Subject: [PATCH] [pajemploi] Detect documents that are not available Some documents may not be available yet, or may have been modified and are not available. Trying to download such documents results in a 500 error. Thus we detect if the documents are available, using the same (javascript) logic as the main site. --- modules/pajemploi/pages.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/pajemploi/pages.py b/modules/pajemploi/pages.py index 00f996c5b3..0bd47e7a79 100644 --- a/modules/pajemploi/pages.py +++ b/modules/pajemploi/pages.py @@ -40,8 +40,10 @@ Format, Field, Eval, + ItemNotFound, ) from weboob.browser.filters.html import Attr, Link, TableCell, FormValue +from weboob.browser.filters.javascript import JSVar from weboob.tools.date import parse_french_date @@ -270,9 +272,17 @@ def get_date(self): def iter_documents(self, proto_doc, subscription): date = self.get_date() + script = CleanText('//script[not(@src)][contains(text(), "traitementEffectue")]') + try: + traitementEffectue = JSVar(script, var='traitementEffectue')(self.doc) + presAnnule = JSVar(script, var='presAnnule')(self.doc) + except ItemNotFound: + traitementEffectue = True + presAnnule = 0 + # Bulletin de salaire frm = self.doc.xpath('//form[@name="formBulletinSalaire"]') - if frm: + if frm and traitementEffectue and (presAnnule == 0): bs = Document() bs.id = "%s_%s" % (proto_doc.id, "bs") bs.date = date @@ -285,7 +295,7 @@ def iter_documents(self, proto_doc, subscription): # Relevé mensuel frm = self.doc.xpath('//form[@name="formReleveMensuel"]') - if frm: + if frm and traitementEffectue and (presAnnule == 0): rm = Document() rm.id = "%s_%s" % (proto_doc.id, "rm") rm.date = date -- GitLab