webcrawlerapi 2.1.3__tar.gz → 2.1.5__tar.gz
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.
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/PKG-INFO +1 -1
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/setup.py +1 -1
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi/__init__.py +2 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi/client.py +26 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi/models.py +8 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi.egg-info/PKG-INFO +1 -1
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/README.md +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/pyproject.toml +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/setup.cfg +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/tests/__init__.py +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/tests/test_client.py +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/tests/test_models.py +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi.egg-info/SOURCES.txt +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi.egg-info/dependency_links.txt +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi.egg-info/requires.txt +0 -0
- {webcrawlerapi-2.1.3 → webcrawlerapi-2.1.5}/webcrawlerapi.egg-info/top_level.txt +0 -0
|
@@ -30,6 +30,7 @@ from .models import (
|
|
|
30
30
|
Job,
|
|
31
31
|
JobItem,
|
|
32
32
|
JobMarkdownResponse,
|
|
33
|
+
MarkdownResponse,
|
|
33
34
|
ScrapeId,
|
|
34
35
|
ScrapeResponse,
|
|
35
36
|
ScrapeResponseError,
|
|
@@ -44,6 +45,7 @@ __all__ = [
|
|
|
44
45
|
"Job",
|
|
45
46
|
"JobItem",
|
|
46
47
|
"JobMarkdownResponse",
|
|
48
|
+
"MarkdownResponse",
|
|
47
49
|
"CrawlResponse",
|
|
48
50
|
"ScrapeId",
|
|
49
51
|
"ScrapeResponse",
|
|
@@ -10,6 +10,7 @@ from .models import (
|
|
|
10
10
|
CrawlResponse,
|
|
11
11
|
Job,
|
|
12
12
|
JobMarkdownResponse,
|
|
13
|
+
MarkdownResponse,
|
|
13
14
|
ScrapeId,
|
|
14
15
|
ScrapeResponse,
|
|
15
16
|
ScrapeResponseError,
|
|
@@ -201,6 +202,31 @@ class WebCrawlerAPI:
|
|
|
201
202
|
self._raise_for_error(response)
|
|
202
203
|
return response.text
|
|
203
204
|
|
|
205
|
+
def markdown(self, url: str) -> MarkdownResponse:
|
|
206
|
+
"""
|
|
207
|
+
Extract cleaned article markdown (main content only) from a webpage.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
url (str): The URL of the webpage to extract the article markdown from
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
MarkdownResponse: Response containing the extracted markdown
|
|
214
|
+
|
|
215
|
+
Raises:
|
|
216
|
+
WebCrawlerApiError: If the API returns an error response
|
|
217
|
+
requests.exceptions.RequestException: If the HTTP request fails
|
|
218
|
+
"""
|
|
219
|
+
response = self.session.post(
|
|
220
|
+
urljoin(self.base_url, "/markdown"),
|
|
221
|
+
json={"url": url},
|
|
222
|
+
)
|
|
223
|
+
if not response.ok:
|
|
224
|
+
self._raise_for_error(response)
|
|
225
|
+
data = response.json()
|
|
226
|
+
return MarkdownResponse(
|
|
227
|
+
success=data.get("success", True), markdown=data.get("markdown")
|
|
228
|
+
)
|
|
229
|
+
|
|
204
230
|
def cancel_job(self, job_id: str) -> Dict[str, str]:
|
|
205
231
|
"""
|
|
206
232
|
Cancel a running job. All items that are not in progress and not done
|
|
@@ -62,6 +62,14 @@ class JobMarkdownResponse:
|
|
|
62
62
|
content_url: str
|
|
63
63
|
|
|
64
64
|
|
|
65
|
+
@dataclass
|
|
66
|
+
class MarkdownResponse:
|
|
67
|
+
"""Response from the markdown endpoint."""
|
|
68
|
+
|
|
69
|
+
success: bool
|
|
70
|
+
markdown: Optional[str] = None
|
|
71
|
+
|
|
72
|
+
|
|
65
73
|
@dataclass
|
|
66
74
|
class ScrapeId:
|
|
67
75
|
"""Response from an asynchronous scrape request."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|