yad2-scraper 0.5.2__py3-none-any.whl → 0.5.3__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.
@@ -7,8 +7,9 @@ from yad2_scraper.vehicles.next_data import VehiclesNextData
7
7
 
8
8
  class Yad2VehiclesCategory(Yad2Category):
9
9
  """Represents a Yad2 vehicles category parsed from an HTML page."""
10
- def get_vehicle_tags(self) -> List[VehicleTag]:
11
- """Retrieve a and return list of vehicle tags from the current category."""
10
+
11
+ def get_tags(self) -> List[VehicleTag]:
12
+ """Retrieve and return a list of tags from the current vehicle page."""
12
13
  tags = self.find_all_tags_by_class_substring("div", "feedItemBox")
13
14
  return [VehicleTag(tag) for tag in tags]
14
15
 
@@ -307,8 +307,10 @@ class VehicleData(metaclass=SafeAccessOptionalKeysMeta):
307
307
  class VehiclesNextData(NextData):
308
308
  """Represents structured Next.js data of a specific vehicle category."""
309
309
 
310
- def iterate_vehicles(self) -> Iterator[VehicleData]:
311
- """Iterates through the queries and yields `VehicleData` objects."""
310
+ def get_data(self) -> List[VehicleData]:
311
+ """Extract and return a list of vehicle-data objects from the stored queries."""
312
+ data_list = []
313
+
312
314
  for query in self.queries:
313
315
  data = query["state"].get("data")
314
316
 
@@ -317,4 +319,6 @@ class VehiclesNextData(NextData):
317
319
 
318
320
  for vehicle_data in itertools.chain.from_iterable(data.values()):
319
321
  if isinstance(vehicle_data, dict):
320
- yield VehicleData(vehicle_data)
322
+ data_list.append(VehicleData(vehicle_data))
323
+
324
+ return data_list
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yad2-scraper
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Scrape Yad2 in Python.
5
5
  License: LICENSE
6
6
  Author: dav ost
@@ -59,9 +59,9 @@ To fetch any category, use the `fetch_category` function:
59
59
  from yad2_scraper import fetch_category, Yad2Category
60
60
 
61
61
  # Fetch real estate category (returns a generic Yad2Category object)
62
- real_estate_category_page1 = fetch_category("https://www.yad2.co.il/realestate/forsale", page=1)
62
+ real_estate_page1 = fetch_category("https://www.yad2.co.il/realestate/forsale", page=1)
63
63
  ...
64
- real_estate_category_page2 = fetch_category("https://www.yad2.co.il/realestate/forsale", page=2)
64
+ real_estate_page2 = fetch_category("https://www.yad2.co.il/realestate/forsale", page=2)
65
65
  ...
66
66
  ```
67
67
 
@@ -75,21 +75,21 @@ from yad2_scraper import fetch_vehicle_category, OrderVehiclesBy, Field
75
75
  # Fetch cars category
76
76
  cars_category = fetch_vehicle_category("cars")
77
77
 
78
- for car_data in cars_category.load_next_data().iterate_vehicles():
78
+ for car_data in cars_category.load_next_data().get_data():
79
79
  print(car_data.model(Field.ENGLISH_TEXT))
80
80
  print(car_data.test_date)
81
81
  print(car_data.price)
82
82
  ...
83
83
 
84
84
  # Fetch motorcycles category
85
- motorcycle_categories = fetch_vehicle_category(
85
+ motorcycle_category = fetch_vehicle_category(
86
86
  "motorcycles",
87
87
  price_range=(5000, 15000),
88
88
  year_range=(2010, 2020),
89
89
  order_by=OrderVehiclesBy.PRICE_LOWEST_TO_HIGHEST
90
90
  )
91
91
 
92
- for motorcycle_tag in motorcycle_categories.get_vehicle_tags():
92
+ for motorcycle_tag in motorcycle_category.get_tags():
93
93
  print(motorcycle_tag.page_link)
94
94
  print(motorcycle_tag.hand)
95
95
  print(motorcycle_tag.price)
@@ -129,22 +129,23 @@ from yad2_scraper.vehicles import (
129
129
  get_vehicle_category_url
130
130
  )
131
131
 
132
- # Fetch businesses for sale category with filters
133
- scraper = Yad2Scraper()
132
+ scraper = Yad2Scraper(request_defaults={"timeout": 5}, max_request_attempts=3)
133
+
134
+ # Fetch businesses-for-sale category with filters
134
135
  url = "https://www.yad2.co.il/products/businesses-for-sale"
135
136
  query_filters = QueryFilters(price_range=(10000, 250000), order_by=OrderBy.PRICE_LOWEST_TO_HIGHEST)
136
- business_for_sale_category = scraper.fetch_category(url, Yad2Category, params=query_filters)
137
+ businesses_for_sale_category = scraper.fetch_category(url, Yad2Category, params=query_filters)
137
138
 
138
- # Fetch watercraft (vehicle) category with filters
139
+ # Fetch watercraft category with filters
139
140
  url = get_vehicle_category_url("watercraft")
140
141
  query_filters = VehiclesQueryFilters(year_range=(2010, 2020), order_by=OrderVehiclesBy.DATE)
141
142
  watercraft_category = scraper.fetch_category(url, Yad2VehiclesCategory, params=query_filters)
142
143
  ```
143
144
 
144
- #### Attributes & Methods
145
+ #### Features & Functionality
145
146
 
146
- The `Yad2Scraper` object contains a lot of additional attributes & methods which you can use.
147
- Please check out the actual code documentation for more details.
147
+ The `Yad2Scraper` class provides various attributes and methods to customize and extend its functionality.
148
+ For detailed usage and examples, refer to the code documentation.
148
149
 
149
150
  ## Contributing
150
151
 
@@ -7,12 +7,12 @@ yad2_scraper/query.py,sha256=6-Xc2qvHYLbejEUij85xWB4mHX3MF1XxPup9oUIkU3w,1503
7
7
  yad2_scraper/scraper.py,sha256=VA-P24Gvn1y5Pkn_n3hDdpVl1aeEnLoC82eBYteAbWQ,11816
8
8
  yad2_scraper/utils.py,sha256=UDpFKel_TJa0dJv1FV-CVqA8-uaFo_hDcooiFAkSZI8,1578
9
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
10
+ yad2_scraper/vehicles/category.py,sha256=_INkTv2Svpj3zytOMANFoBAmTvzfkhdOUm0bs6HrrWI,805
11
+ yad2_scraper/vehicles/next_data.py,sha256=QHAa8AMz7NJ9r0tDVMZ0iLhhIxM2qWgnkV07t5RYjSQ,9330
12
12
  yad2_scraper/vehicles/query.py,sha256=N0kA1Ci_MexPXfNpa9EUkXf8XLYOr6np9jMMMpVOlaM,986
13
13
  yad2_scraper/vehicles/tag.py,sha256=Wj7v2c8IPQLYHVkfzP1UiulKKJE4yLqnbeh81nvWZhU,2052
14
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,,
15
+ yad2_scraper-0.5.3.dist-info/LICENSE,sha256=JCpnDxMx2kE40e0UQ1svSmifrLWg2Gni5VTkJR68thY,1065
16
+ yad2_scraper-0.5.3.dist-info/METADATA,sha256=X6MaY2hRMU-DO5F-bGmJUoBWOZ7doYgHdfR0_ZjnzFU,5259
17
+ yad2_scraper-0.5.3.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
18
+ yad2_scraper-0.5.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.0
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any