Spaces:
Sleeping
Sleeping
Modified web scrapper
Browse files- code/web_scraper_olx.py +9 -0
code/web_scraper_olx.py
CHANGED
|
@@ -56,6 +56,14 @@ def get_olx_data(url):
|
|
| 56 |
title_element = soup.find("h4", class_="css-1au435n")
|
| 57 |
title = title_element.get_text().strip() if title_element else "untitled"
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
# Description
|
| 60 |
description_element = soup.find("div", class_="css-19duwlz")
|
| 61 |
description = (
|
|
@@ -83,6 +91,7 @@ def get_olx_data(url):
|
|
| 83 |
"platform": "OLX",
|
| 84 |
"title": title,
|
| 85 |
"sanitized_title": sanitize_name(title),
|
|
|
|
| 86 |
"url": url,
|
| 87 |
"description": description,
|
| 88 |
"parameters": parameter_list,
|
|
|
|
| 56 |
title_element = soup.find("h4", class_="css-1au435n")
|
| 57 |
title = title_element.get_text().strip() if title_element else "untitled"
|
| 58 |
|
| 59 |
+
# Price
|
| 60 |
+
price = "No price"
|
| 61 |
+
price_container = soup.find("div", attrs={"data-testid": "ad-price-container"})
|
| 62 |
+
if price_container:
|
| 63 |
+
price_header = price_container.find("h3")
|
| 64 |
+
if price_header:
|
| 65 |
+
price = price_header.get_text(strip=True)
|
| 66 |
+
|
| 67 |
# Description
|
| 68 |
description_element = soup.find("div", class_="css-19duwlz")
|
| 69 |
description = (
|
|
|
|
| 91 |
"platform": "OLX",
|
| 92 |
"title": title,
|
| 93 |
"sanitized_title": sanitize_name(title),
|
| 94 |
+
"price": price,
|
| 95 |
"url": url,
|
| 96 |
"description": description,
|
| 97 |
"parameters": parameter_list,
|