Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blocket_api/ad_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RecommerceAd:
def url(self) -> str:
return f"{SITE_URL}/recommerce/forsale/item/{self.id}"

def parse(self, response: Response) -> Any:
def parse(self, response: Response) -> dict[str, Any]:
soup = BeautifulSoup(response.content, "html.parser")
json_script_tag = soup.select_one(
'script:-soup-contains("window.__staticRouterHydrationData")'
Expand All @@ -41,7 +41,7 @@ class MobilityAd:
def url(self) -> str:
return f"{SITE_URL}/mobility/item/{self.id}"

def parse(self, response: Response) -> dict:
def parse(self, response: Response) -> dict[str, Any]:
soup = BeautifulSoup(response.content, "html.parser")
grid = soup.find("div", class_="grid grid-cols-1 md:grid-cols-3 md:gap-x-32")

Expand Down
8 changes: 4 additions & 4 deletions blocket_api/blocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def search(
locations: list[Location] = [],
category: Category | None = None,
sub_category: SubCategory | None = None,
) -> Any:
) -> dict[str, Any]:
if category and sub_category:
raise AssertionError("Cannot specify both category and sub_categories")

Expand Down Expand Up @@ -88,7 +88,7 @@ def search_car(
milage_to: int | None = None,
colors: list[CarColor] = [],
transmissions: list[CarTransmission] = [],
) -> Any:
) -> dict[str, Any]:
url = f"{SITE_URL}/mobility/search/api/search/SEARCH_ID_CAR_USED"

param_dict: dict[str, str | int | None] = {
Expand Down Expand Up @@ -158,7 +158,7 @@ def search_mc(
price_to: int | None = None,
engine_volume_from: int | None = None,
engine_volume_to: int | None = None,
) -> Any:
) -> dict[str, Any]:
url = f"{SITE_URL}/mobility/search/api/search/SEARCH_ID_MC_USED"

param_dict: dict[str, str | int | None] = {
Expand All @@ -179,6 +179,6 @@ def search_mc(

return _request(url=url, params=params).json()

def get_ad(self, ad: RecommerceAd | CarAd | BoatAd | McAd) -> dict:
def get_ad(self, ad: RecommerceAd | CarAd | BoatAd | McAd) -> dict[str, Any]:
response = _request(url=ad.url, params=[])
return ad.parse(response)