yad2-scraper 0.5.1__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/PKG-INFO +2 -2
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/README.md +1 -1
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/pyproject.toml +1 -1
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/exceptions.py +0 -3
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/next_data.py +1 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/query.py +1 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/vehicles/category.py +1 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/vehicles/next_data.py +4 -4
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/vehicles/query.py +1 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/LICENSE +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/__init__.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/category.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/constants.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/scraper.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/utils.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/vehicles/__init__.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/vehicles/tag.py +0 -0
- {yad2_scraper-0.5.1 → yad2_scraper-0.5.2}/yad2_scraper/vehicles/urls.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: yad2-scraper
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: Scrape Yad2 in Python.
|
5
5
|
License: LICENSE
|
6
6
|
Author: dav ost
|
@@ -133,7 +133,7 @@ from yad2_scraper.vehicles import (
|
|
133
133
|
scraper = Yad2Scraper()
|
134
134
|
url = "https://www.yad2.co.il/products/businesses-for-sale"
|
135
135
|
query_filters = QueryFilters(price_range=(10000, 250000), order_by=OrderBy.PRICE_LOWEST_TO_HIGHEST)
|
136
|
-
|
136
|
+
business_for_sale_category = scraper.fetch_category(url, Yad2Category, params=query_filters)
|
137
137
|
|
138
138
|
# Fetch watercraft (vehicle) category with filters
|
139
139
|
url = get_vehicle_category_url("watercraft")
|
@@ -110,7 +110,7 @@ from yad2_scraper.vehicles import (
|
|
110
110
|
scraper = Yad2Scraper()
|
111
111
|
url = "https://www.yad2.co.il/products/businesses-for-sale"
|
112
112
|
query_filters = QueryFilters(price_range=(10000, 250000), order_by=OrderBy.PRICE_LOWEST_TO_HIGHEST)
|
113
|
-
|
113
|
+
business_for_sale_category = scraper.fetch_category(url, Yad2Category, params=query_filters)
|
114
114
|
|
115
115
|
# Fetch watercraft (vehicle) category with filters
|
116
116
|
url = get_vehicle_category_url("watercraft")
|
@@ -6,7 +6,6 @@ class ResponseError(Exception):
|
|
6
6
|
"""Represents an error response from an HTTP request."""
|
7
7
|
|
8
8
|
def __init__(self, msg: str, request: httpx.Request, response: httpx.Response):
|
9
|
-
"""Initialize with an error message, request, and response objects."""
|
10
9
|
super().__init__(msg)
|
11
10
|
self.request = request
|
12
11
|
self.response = response
|
@@ -26,7 +25,6 @@ class MaxAttemptsExceededError(Exception):
|
|
26
25
|
"""Raised when the maximum number of attempts is exceeded."""
|
27
26
|
|
28
27
|
def __init__(self, msg: str, max_attempts: int, errors: List[BaseException] = None):
|
29
|
-
"""Initialize with an error message, max attempts, and optional errors."""
|
30
28
|
super().__init__(msg)
|
31
29
|
self.max_attempts = max_attempts
|
32
30
|
self.errors = errors
|
@@ -36,7 +34,6 @@ class MaxRequestAttemptsExceededError(MaxAttemptsExceededError):
|
|
36
34
|
"""Raised when all HTTP request attempts fail."""
|
37
35
|
|
38
36
|
def __init__(self, method: str, url: str, max_attempts: int, errors: List[Union[httpx.HTTPError, ResponseError]]):
|
39
|
-
"""Initialize with request method, URL, max attempts, and error list."""
|
40
37
|
msg = f"All {max_attempts} attempts for {method} request to '{url}' have failed"
|
41
38
|
super().__init__(msg, max_attempts, errors)
|
42
39
|
self.method = method
|
@@ -6,6 +6,7 @@ from yad2_scraper.vehicles.next_data import VehiclesNextData
|
|
6
6
|
|
7
7
|
|
8
8
|
class Yad2VehiclesCategory(Yad2Category):
|
9
|
+
"""Represents a Yad2 vehicles category parsed from an HTML page."""
|
9
10
|
def get_vehicle_tags(self) -> List[VehicleTag]:
|
10
11
|
"""Retrieve a and return list of vehicle tags from the current category."""
|
11
12
|
tags = self.find_all_tags_by_class_substring("div", "feedItemBox")
|
@@ -14,7 +14,7 @@ from yad2_scraper.vehicles.urls import VEHICLES_URL
|
|
14
14
|
|
15
15
|
|
16
16
|
class VehicleData(metaclass=SafeAccessOptionalKeysMeta):
|
17
|
-
"""Represents
|
17
|
+
"""Represents the data for a single vehicle."""
|
18
18
|
|
19
19
|
def __init__(self, data: dict):
|
20
20
|
self.data = data
|
@@ -305,7 +305,10 @@ class VehicleData(metaclass=SafeAccessOptionalKeysMeta):
|
|
305
305
|
|
306
306
|
|
307
307
|
class VehiclesNextData(NextData):
|
308
|
+
"""Represents structured Next.js data of a specific vehicle category."""
|
309
|
+
|
308
310
|
def iterate_vehicles(self) -> Iterator[VehicleData]:
|
311
|
+
"""Iterates through the queries and yields `VehicleData` objects."""
|
309
312
|
for query in self.queries:
|
310
313
|
data = query["state"].get("data")
|
311
314
|
|
@@ -315,6 +318,3 @@ class VehiclesNextData(NextData):
|
|
315
318
|
for vehicle_data in itertools.chain.from_iterable(data.values()):
|
316
319
|
if isinstance(vehicle_data, dict):
|
317
320
|
yield VehicleData(vehicle_data)
|
318
|
-
|
319
|
-
def __getitem__(self, item):
|
320
|
-
return self.data[item]
|
@@ -5,6 +5,7 @@ from yad2_scraper.query import QueryFilters, OrderBy, NumberRange, format_number
|
|
5
5
|
|
6
6
|
|
7
7
|
class OrderVehiclesBy(int, Enum):
|
8
|
+
"""Enum representing different order options for sorting vehicles."""
|
8
9
|
DATE = OrderBy.DATE
|
9
10
|
PRICE_LOWEST_TO_HIGHEST = OrderBy.PRICE_LOWEST_TO_HIGHEST
|
10
11
|
PRICE_HIGHEST_TO_LOWEST = OrderBy.PRICE_HIGHEST_TO_LOWEST
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|