Skip to content

Commit 01c8134

Browse files
committed
minor
1 parent b203900 commit 01c8134

5 files changed

Lines changed: 103 additions & 10 deletions

File tree

chizhik_api/endpoints/advertising.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ async def active_inout(self) -> FetchResponse:
2222
"""Получить активные рекламные баннеры."""
2323
return await self._parent._request(
2424
HttpMethod.GET,
25-
f"{self._parent.CATALOG_URL}/catalog/unauthorized/active_inout/",
25+
f"{self._parent.API_URL}/v1/catalog/unauthorized/active_inout/",
2626
)

chizhik_api/endpoints/catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, parent: "ChizhikAPI"):
3333
@autotest
3434
async def tree(self, city_id: Optional[str] = None) -> FetchResponse:
3535
"""Получить дерево категорий."""
36-
url = f"{self._parent.CATALOG_URL}/catalog/unauthorized/categories/"
36+
url = f"{self._parent.API_URL}/v1/catalog/unauthorized/categories/"
3737
if city_id:
3838
url += f"?city_id={city_id}"
3939
return await self._parent._request(HttpMethod.GET, url)
@@ -47,7 +47,7 @@ async def products_list(
4747
search: Optional[str] = None,
4848
) -> FetchResponse:
4949
"""Получить список продуктов в категории."""
50-
url = f"{self._parent.CATALOG_URL}/catalog/unauthorized/products/?page={page}"
50+
url = f"{self._parent.API_URL}/v1/catalog/unauthorized/products/?page={page}"
5151
if category_id:
5252
url += f"&category_id={category_id}"
5353
if city_id:
@@ -74,7 +74,7 @@ async def info(
7474
Response: Ответ от сервера с информацией о товаре.
7575
"""
7676

77-
url = f"{self._parent.CATALOG_URL}/catalog/unauthorized/products/{product_id}/"
77+
url = f"{self._parent.API_URL}/v1/catalog/unauthorized/products/{product_id}/"
7878
if city_id:
7979
url += f"?city_id={city_id}"
8080
return await self._parent._request(HttpMethod.GET, url)

chizhik_api/endpoints/geolocation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def cities_list(self, search_name: str, page: int = 1) -> FetchResponse:
3333
"""Получить список городов по частичному совпадению имени."""
3434
return await self._parent._request(
3535
HttpMethod.GET,
36-
f"{self._parent.CATALOG_URL}/geo/cities/?name={search_name}&page={page}",
36+
f"{self._parent.API_URL}/v1/geo/cities/?name={search_name}&page={page}",
3737
)
3838

3939
class ShopService(ApiChild["ChizhikAPI"]):
@@ -42,11 +42,11 @@ class ShopService(ApiChild["ChizhikAPI"]):
4242
@autotest
4343
async def all(self) -> FetchResponse:
4444
"""Получить список всех точек магазинов."""
45-
url = f"{self._parent.CATALOG_URL}/shops"
45+
url = f"{self._parent.API_URL}/v1/shops"
4646
return await self._parent._request(HttpMethod.GET, url)
4747

4848
@autotest
4949
async def search(self, query: str) -> FetchResponse:
5050
"""Получить список всех точек магазинов."""
51-
url = f"{self._parent.CATALOG_URL}/shops?term={query}"
51+
url = f"{self._parent.API_URL}/v1/shops?term={query}"
5252
return await self._parent._request(HttpMethod.GET, url)

chizhik_api/manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class ChizhikAPI(ApiParent):
4444
Принимает как формат Playwright, так и строчный формат."""
4545
browser_opts: dict[str, Any] = field(default_factory=dict)
4646
"""Дополнительные опции для браузера (см. https://camoufox.com/python/installation/)"""
47-
CATALOG_URL: str = "https://app.chizhik.club/api/v1"
4847
API_URL: str = "https://app.chizhik.club/api"
4948
"""URL для работы с каталогом."""
5049
MAIN_SITE_URL: str = "https://chizhik.club/catalog/"
@@ -99,7 +98,7 @@ async def _warmup(self) -> None:
9998
if self.test_mode:
10099
sniffer = HeaderAnomalySniffer(
101100
include_subresources=True, # или False, если интересны только документы
102-
url_filter=lambda u: u.startswith(self.CATALOG_URL),
101+
url_filter=lambda u: u.startswith(self.API_URL),
103102
)
104103
await sniffer.start(self.ctx)
105104

@@ -133,7 +132,7 @@ def on_request(request):
133132
self.unstandard_headers = {k: list(v)[0] for k, v in result.items()}
134133
self.unstandard_urls = collected
135134

136-
await self.page.goto(self.CATALOG_URL, wait_until="networkidle")
135+
await self.page.goto(f"{self.API_URL}/v1", wait_until="networkidle")
137136

138137
await self.page.wait_for_selector(
139138
"pre", timeout=self.timeout_ms, state="attached"

tests/__snapshots__/unstandard_urls.schema.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,100 @@
585585
}
586586
}
587587
},
588+
"https://app.chizhik.club/api/v1/shops/?term=%D0%9C%D0%B0%D0%BC%D0%BE%D0%BD%D0%BE%D0%B2%D0%BE": {
589+
"type": "object",
590+
"required": [
591+
"accept",
592+
"accept-encoding",
593+
"accept-language",
594+
"connection",
595+
"host",
596+
"origin",
597+
"referer",
598+
"sec-fetch-dest",
599+
"sec-fetch-mode",
600+
"sec-fetch-site",
601+
"user-agent"
602+
],
603+
"properties": {
604+
"accept": {
605+
"type": "string"
606+
},
607+
"accept-encoding": {
608+
"type": "string"
609+
},
610+
"accept-language": {
611+
"type": "string"
612+
},
613+
"connection": {
614+
"type": "string"
615+
},
616+
"host": {
617+
"type": "string"
618+
},
619+
"origin": {
620+
"type": "string",
621+
"format": "uri"
622+
},
623+
"referer": {
624+
"type": "string",
625+
"format": "uri"
626+
},
627+
"sec-fetch-dest": {
628+
"type": "string"
629+
},
630+
"sec-fetch-mode": {
631+
"type": "string"
632+
},
633+
"sec-fetch-site": {
634+
"type": "string"
635+
},
636+
"user-agent": {
637+
"type": "string"
638+
}
639+
}
640+
},
641+
"https://app.chizhik.club/api/v1/shops/?term=%D0%9C%D0%B0%D0%BC%D0%BE%D0%BD%D0%BE%D0%B2%D0%BE&utm_referrer=https%3a%2f%2fchizhik.club%2f": {
642+
"type": "object",
643+
"required": [
644+
"accept",
645+
"accept-encoding",
646+
"accept-language",
647+
"connection",
648+
"host",
649+
"origin",
650+
"referer",
651+
"user-agent"
652+
],
653+
"properties": {
654+
"accept": {
655+
"type": "string"
656+
},
657+
"accept-encoding": {
658+
"type": "string"
659+
},
660+
"accept-language": {
661+
"type": "string"
662+
},
663+
"connection": {
664+
"type": "string"
665+
},
666+
"host": {
667+
"type": "string"
668+
},
669+
"origin": {
670+
"type": "string",
671+
"format": "uri"
672+
},
673+
"referer": {
674+
"type": "string",
675+
"format": "uri"
676+
},
677+
"user-agent": {
678+
"type": "string"
679+
}
680+
}
681+
},
588682
"https://app.chizhik.club/api/v1/shops/?term=%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0": {
589683
"type": "object",
590684
"required": [

0 commit comments

Comments
 (0)