Skip to content

Commit 44a8037

Browse files
authored
Merge pull request #663 from codders/feat/fix-immobiliare-20241217
Handle flats with more than 5 rooms on immobiliare
2 parents 511001b + 71266a7 commit 44a8037

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: flathunter/crawler/immobiliare.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def extract_data(self, soup):
5555

5656
detail_texts = [ item.find("span").text.strip() for item in details_list ]
5757
room_counts = [ match.group(1) for text in detail_texts
58-
if (match := re.match(r"(\d+) local[ie]", text)) is not None ]
58+
if (match := re.match(r"(\d+)\+? local[ie]", text)) is not None ]
5959
if len(room_counts) > 0:
6060
rooms = room_counts[0]
6161
else:

Diff for: test/crawler/test_crawl_immobiliare.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ def test(self):
2424
self.assertTrue(entries[0]['url'].startswith(
2525
"https://www.immobiliare.it/annunci/"), u"URL should be an apartment link")
2626
for attr in ['title', 'price', 'size', 'rooms', 'address', 'image']:
27-
self.assertIsNotNone(entries[0][attr], attr + " should be set")
27+
self.assertIsNotNone(
28+
entries[0][attr], attr + " should be set (" + entries[0]['url'] + ")"
29+
)

0 commit comments

Comments
 (0)