yad2-scraper 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl

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.
@@ -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
yad2_scraper/next_data.py CHANGED
@@ -27,6 +27,7 @@ class SafeAccessOptionalKeysMeta(type):
27
27
 
28
28
 
29
29
  class Field(str, Enum):
30
+ """Enum representing different field types for data."""
30
31
  ID = "id"
31
32
  TEXT = "text"
32
33
  ENGLISH_TEXT = "textEng"
yad2_scraper/query.py CHANGED
@@ -6,6 +6,7 @@ NumberRange = Tuple[int, int]
6
6
 
7
7
 
8
8
  class OrderBy(int, Enum):
9
+ """Enum representing different order options for sorting."""
9
10
  DATE = 1
10
11
  PRICE_LOWEST_TO_HIGHEST = 3
11
12
  PRICE_HIGHEST_TO_LOWEST = 4
@@ -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 structured Next.js data of a specific vehicle category."""
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yad2-scraper
3
- Version: 0.5.1
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
- real_estate_category = scraper.fetch_category(url, Yad2Category, params=query_filters)
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")
@@ -0,0 +1,18 @@
1
+ yad2_scraper/__init__.py,sha256=oLANQo7jrtR5ex1tv4sM5ppaW9JpHS70Knsp0ZgVzm0,3708
2
+ yad2_scraper/category.py,sha256=SQ2eg0-fQ9hEaNryYpWVFaJqCx1d65t2_E_S3qpuw9g,1230
3
+ yad2_scraper/constants.py,sha256=8zXJ31fRqkDIOJp96BRK1PJofGXX8SG64YcfmJnVW8Q,910
4
+ yad2_scraper/exceptions.py,sha256=CC7LUy5hMQRTI48UqLZBvYJAYkVZD6n05HXeGWAIO5w,1283
5
+ yad2_scraper/next_data.py,sha256=k8Hkd_fMaAvVWHC6cizuv2osi9c_pJoKjo6mKqfJNEY,2037
6
+ yad2_scraper/query.py,sha256=6-Xc2qvHYLbejEUij85xWB4mHX3MF1XxPup9oUIkU3w,1503
7
+ yad2_scraper/scraper.py,sha256=VA-P24Gvn1y5Pkn_n3hDdpVl1aeEnLoC82eBYteAbWQ,11816
8
+ yad2_scraper/utils.py,sha256=UDpFKel_TJa0dJv1FV-CVqA8-uaFo_hDcooiFAkSZI8,1578
9
+ yad2_scraper/vehicles/__init__.py,sha256=dxjZcNv3ExnN3fKW-m1oqKiX9YC7gj8lqpIa3uWo9iI,242
10
+ yad2_scraper/vehicles/category.py,sha256=KGx_0Rh3QfC0kUf8ndRrFqCVuzzl8mhKi0Fkxxcp1bA,816
11
+ yad2_scraper/vehicles/next_data.py,sha256=4GofUS9InAY7g7xtg6MKVr3tWN6-LS9dGBYC5vwx6QU,9268
12
+ yad2_scraper/vehicles/query.py,sha256=N0kA1Ci_MexPXfNpa9EUkXf8XLYOr6np9jMMMpVOlaM,986
13
+ yad2_scraper/vehicles/tag.py,sha256=Wj7v2c8IPQLYHVkfzP1UiulKKJE4yLqnbeh81nvWZhU,2052
14
+ yad2_scraper/vehicles/urls.py,sha256=zxipWjm0SXn2gGOBWw9VqKAJ59mhIGpzd_fTYitpW8c,715
15
+ yad2_scraper-0.5.2.dist-info/LICENSE,sha256=JCpnDxMx2kE40e0UQ1svSmifrLWg2Gni5VTkJR68thY,1065
16
+ yad2_scraper-0.5.2.dist-info/METADATA,sha256=Yk4fZ8_OxjL0MsTYhXO4DA8mP2opOQGDBuQFhJA0ivw,5231
17
+ yad2_scraper-0.5.2.dist-info/WHEEL,sha256=7dDg4QLnNKTvwIDR9Ac8jJaAmBC_owJrckbC0jjThyA,88
18
+ yad2_scraper-0.5.2.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- yad2_scraper/__init__.py,sha256=oLANQo7jrtR5ex1tv4sM5ppaW9JpHS70Knsp0ZgVzm0,3708
2
- yad2_scraper/category.py,sha256=SQ2eg0-fQ9hEaNryYpWVFaJqCx1d65t2_E_S3qpuw9g,1230
3
- yad2_scraper/constants.py,sha256=8zXJ31fRqkDIOJp96BRK1PJofGXX8SG64YcfmJnVW8Q,910
4
- yad2_scraper/exceptions.py,sha256=5yentEUBuEGItwRcjtZY89A19rvFErcTy4S4GUtY_WY,1526
5
- yad2_scraper/next_data.py,sha256=OcZ7ingXSd6sLNkqQPz6NVTeEDbMkOai9QONFErc3FI,1977
6
- yad2_scraper/query.py,sha256=HPBoLE6xFjsmvBFR2ULvPq96XXl-2zOqXt7LnHgetIk,1438
7
- yad2_scraper/scraper.py,sha256=VA-P24Gvn1y5Pkn_n3hDdpVl1aeEnLoC82eBYteAbWQ,11816
8
- yad2_scraper/utils.py,sha256=UDpFKel_TJa0dJv1FV-CVqA8-uaFo_hDcooiFAkSZI8,1578
9
- yad2_scraper/vehicles/__init__.py,sha256=dxjZcNv3ExnN3fKW-m1oqKiX9YC7gj8lqpIa3uWo9iI,242
10
- yad2_scraper/vehicles/category.py,sha256=HdUGCVpC1jw2V-2XvyAC4pPlVQR6cwHyVKDxS3pfQhc,744
11
- yad2_scraper/vehicles/next_data.py,sha256=lEIWcTP7BOFDC3lL0FhBGp6u-7hsgGdbbrH0iw0Ux20,9203
12
- yad2_scraper/vehicles/query.py,sha256=ieIJSGJELcgzqtJh6bQXalvDg743LnI2RYrAyHDIH80,912
13
- yad2_scraper/vehicles/tag.py,sha256=Wj7v2c8IPQLYHVkfzP1UiulKKJE4yLqnbeh81nvWZhU,2052
14
- yad2_scraper/vehicles/urls.py,sha256=zxipWjm0SXn2gGOBWw9VqKAJ59mhIGpzd_fTYitpW8c,715
15
- yad2_scraper-0.5.1.dist-info/LICENSE,sha256=JCpnDxMx2kE40e0UQ1svSmifrLWg2Gni5VTkJR68thY,1065
16
- yad2_scraper-0.5.1.dist-info/METADATA,sha256=SLeA6BPi1idJ20WWWbl7AW-hC_u1_vKPRmUTg4_VhVI,5225
17
- yad2_scraper-0.5.1.dist-info/WHEEL,sha256=7dDg4QLnNKTvwIDR9Ac8jJaAmBC_owJrckbC0jjThyA,88
18
- yad2_scraper-0.5.1.dist-info/RECORD,,