diff --git a/core/pyproject.toml b/core/pyproject.toml index 4093f25..16f75f6 100644 --- a/core/pyproject.toml +++ b/core/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "harambe-core" -version = "0.60.1" +version = "0.60.2" description = "Core types for harambe SDK 🐒🍌" authors = [ { name = "Adam Watkins", email = "adam@reworkd.ai" } diff --git a/core/uv.lock b/core/uv.lock index 6b8c419..491832e 100644 --- a/core/uv.lock +++ b/core/uv.lock @@ -115,7 +115,7 @@ wheels = [ [[package]] name = "harambe-core" -version = "0.59.5" +version = "0.60.2" source = { virtual = "." } dependencies = [ { name = "dateparser" }, @@ -502,7 +502,7 @@ name = "tzlocal" version = "5.2" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "tzdata", marker = "platform_system == 'Windows'" }, + { name = "tzdata", marker = "sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/04/d3/c19d65ae67636fe63953b20c2e4a8ced4497ea232c43ff8d01db16de8dc0/tzlocal-5.2.tar.gz", hash = "sha256:8d399205578f1a9342816409cc1e46a93ebd5755e39ea2d85334bea911bf0e6e", size = 30201 } wheels = [ diff --git a/sdk/harambe/contrib/soup/impl.py b/sdk/harambe/contrib/soup/impl.py index 5a3b37b..9399d2a 100644 --- a/sdk/harambe/contrib/soup/impl.py +++ b/sdk/harambe/contrib/soup/impl.py @@ -4,7 +4,7 @@ import json # noinspection PyProtectedMember -from curl_cffi.requests import AsyncSession, HeaderTypes +from curl_cffi.requests import AsyncSession, HeaderTypes, Response from harambe.contrib.soup.tracing import Tracer from harambe.contrib.types import AbstractElementHandle, AbstractPage, Selectable from harambe.contrib.types import ResponseWithStatus @@ -92,37 +92,38 @@ async def post( self, url: str, data: dict[str, Any], + params: Optional[dict[str, Any]] = None, headers: Optional[HeaderTypes] = None, **kwargs: Any, - ) -> Any: + ) -> Response: + content_type = ( + (headers or self._extra_headers or {}).get("Content-Type", "").lower() + ) + + processed_data = ( + json.dumps(data) if "application/json" in content_type else data + ) res = await self._session.post( url, headers=headers or self._extra_headers, - data=json.dumps(data), + data=processed_data, + params=params or {}, impersonate="chrome", **kwargs, ) + res.raise_for_status() + if self._tracer: self._tracer.log_request(res) self._url = res.url content_type = res.headers.get("Content-Type", "") - if "application/json" in content_type: - - class SoupResponseWithStatus: - status: int = res.status_code - body: dict[str, Any] = res.json() - - return SoupResponseWithStatus() + return res self._soup = BeautifulSoup(res.text, "html.parser") - class SoupResponseWithStatus: - status: int = res.status_code - body: str = res.text - - return SoupResponseWithStatus() + return res async def query_selector_all(self, selector: str) -> list[SoupElementHandle]: return SoupElementHandle.from_tags(self._soup.select(selector)) diff --git a/sdk/pyproject.toml b/sdk/pyproject.toml index 53b4a9c..840f576 100644 --- a/sdk/pyproject.toml +++ b/sdk/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "harambe-sdk" -version = "0.60.1" +version = "0.60.2" description = "Data extraction SDK for Playwright 🐒🍌" authors = [ { name = "Adam Watkins", email = "adam@reworkd.ai" } @@ -8,7 +8,7 @@ authors = [ requires-python = ">=3.11,<4.0" readme = "README.md" dependencies = [ - "harambe_core==0.60.1", + "harambe_core==0.60.2", "playwright==1.47.0", "beautifulsoup4==4.12.3", "requests==2.32.3", diff --git a/sdk/uv.lock b/sdk/uv.lock index ebbac89..39d45ed 100644 --- a/sdk/uv.lock +++ b/sdk/uv.lock @@ -428,7 +428,7 @@ wheels = [ [[package]] name = "harambe-core" -version = "0.59.5" +version = "0.60.2" source = { editable = "../core" } dependencies = [ { name = "dateparser" }, @@ -459,7 +459,7 @@ dev = [ [[package]] name = "harambe-sdk" -version = "0.59.5" +version = "0.60.2" source = { virtual = "." } dependencies = [ { name = "aiohttp" }, @@ -1053,7 +1053,7 @@ name = "tzlocal" version = "5.2" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "tzdata", marker = "platform_system == 'Windows'" }, + { name = "tzdata", marker = "sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/04/d3/c19d65ae67636fe63953b20c2e4a8ced4497ea232c43ff8d01db16de8dc0/tzlocal-5.2.tar.gz", hash = "sha256:8d399205578f1a9342816409cc1e46a93ebd5755e39ea2d85334bea911bf0e6e", size = 30201 } wheels = [