Browse Source

Fix modules

Phyks (Lucas Verney) 7 months ago
parent
commit
28270a15b9
2 changed files with 15 additions and 2 deletions
  1. 10
    1
      modules/pap/pages.py
  2. 5
    1
      modules/seloger/pages.py

+ 10
- 1
modules/pap/pages.py View File

@@ -49,6 +49,8 @@ class HousingPage(HTMLPage):
49 49
     @method
50 50
     class iter_housings(ListElement):
51 51
         item_xpath = '//div[has-class("search-list-item-alt")]'
52
+        # Prevent DataError on same ids
53
+        ignore_duplicate = True
52 54
 
53 55
         def next_page(self):
54 56
             return Link('//ul[@class="pagination"]/li[@class="next"]/a')(self)
@@ -61,6 +63,9 @@ class HousingPage(HTMLPage):
61 63
                 isNotFurnishedOk = True
62 64
                 if self.env['query_type'] == POSTS_TYPES.RENT:
63 65
                     isNotFurnishedOk = 'meublé' not in title.lower()
66
+                id = self.obj_id(self)
67
+                if id is None:
68
+                    return False
64 69
                 return (
65 70
                     Regexp(Link('./div/a[has-class("item-title")]'), '/annonces/(.*)', default=None)(self) and
66 71
                     isNotFurnishedOk
@@ -94,7 +99,11 @@ class HousingPage(HTMLPage):
94 99
                         )(item)
95 100
                     self.env[name] = value
96 101
 
97
-            obj_id = Regexp(Link('./div/a[has-class("item-title")]'), '/annonces/(.*)')
102
+            obj_id = Regexp(
103
+                Link('./div/a[has-class("item-title")]'), '/annonces/(.*)',
104
+                default=None
105
+            )
106
+
98 107
             obj_type = Env('query_type')
99 108
             obj_advert_type = ADVERT_TYPES.PERSONAL
100 109
 

+ 5
- 1
modules/seloger/pages.py View File

@@ -81,7 +81,11 @@ class SearchResultsPage(HTMLPage):
81 81
             klass = Housing
82 82
 
83 83
             def condition(self):
84
-                return Dict('cardType')(self) not in ['advertising', 'localExpert'] and Dict('id', default=False)(self)
84
+                return (
85
+                    Dict('cardType')(self) not in ['advertising', 'localExpert']
86
+                    and Dict('id', default=False)(self)
87
+                    and Dict('classifiedURL', default=False)(self)
88
+                )
85 89
 
86 90
             obj_id = Dict('id')
87 91