Skip to content

Commit

Permalink
Merge pull request #663 from codders/feat/fix-immobiliare-20241217
Browse files Browse the repository at this point in the history
Handle flats with more than 5 rooms on immobiliare
  • Loading branch information
codders authored Dec 17, 2024
2 parents 511001b + 71266a7 commit 44a8037
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flathunter/crawler/immobiliare.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def extract_data(self, soup):

detail_texts = [ item.find("span").text.strip() for item in details_list ]
room_counts = [ match.group(1) for text in detail_texts
if (match := re.match(r"(\d+) local[ie]", text)) is not None ]
if (match := re.match(r"(\d+)\+? local[ie]", text)) is not None ]
if len(room_counts) > 0:
rooms = room_counts[0]
else:
Expand Down
4 changes: 3 additions & 1 deletion test/crawler/test_crawl_immobiliare.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ def test(self):
self.assertTrue(entries[0]['url'].startswith(
"https://www.immobiliare.it/annunci/"), u"URL should be an apartment link")
for attr in ['title', 'price', 'size', 'rooms', 'address', 'image']:
self.assertIsNotNone(entries[0][attr], attr + " should be set")
self.assertIsNotNone(
entries[0][attr], attr + " should be set (" + entries[0]['url'] + ")"
)

0 comments on commit 44a8037

Please sign in to comment.