webcrawlerapi 2.0.3__tar.gz → 2.0.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.0.3 → webcrawlerapi-2.0.5}/PKG-INFO +3 -3
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/README.md +2 -2
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/setup.py +1 -1
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi/client.py +8 -7
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi.egg-info/PKG-INFO +3 -3
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/setup.cfg +0 -0
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi/__init__.py +0 -0
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi/models.py +0 -0
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi.egg-info/SOURCES.txt +0 -0
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi.egg-info/dependency_links.txt +0 -0
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi.egg-info/requires.txt +0 -0
- {webcrawlerapi-2.0.3 → webcrawlerapi-2.0.5}/webcrawlerapi.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webcrawlerapi
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5
|
|
4
4
|
Summary: Python SDK for WebCrawler API
|
|
5
5
|
Home-page: https://github.com/webcrawlerapi/webcrawlerapi-python-sdk
|
|
6
6
|
Author: Andrew
|
|
@@ -101,11 +101,11 @@ print(f"Cancellation response: {cancel_response['message']}")
|
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
### Scraping
|
|
104
|
-
|
|
104
|
+
Check a working code example of [scraping](https://github.com/WebCrawlerAPI/webcrawlerapi-examples/tree/master/python/scraping) and [scraping with a prompt](https://github.com/WebCrawlerAPI/webcrawlerapi-examples/tree/master/python/scraping_prompt)
|
|
105
105
|
```python
|
|
106
106
|
# Returns structured data directly
|
|
107
107
|
response = crawler.scrape(
|
|
108
|
-
|
|
108
|
+
url="https://webcrawlerapi.com"
|
|
109
109
|
)
|
|
110
110
|
if response.success:
|
|
111
111
|
print(response.markdown)
|
|
@@ -80,11 +80,11 @@ print(f"Cancellation response: {cancel_response['message']}")
|
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
### Scraping
|
|
83
|
-
|
|
83
|
+
Check a working code example of [scraping](https://github.com/WebCrawlerAPI/webcrawlerapi-examples/tree/master/python/scraping) and [scraping with a prompt](https://github.com/WebCrawlerAPI/webcrawlerapi-examples/tree/master/python/scraping_prompt)
|
|
84
84
|
```python
|
|
85
85
|
# Returns structured data directly
|
|
86
86
|
response = crawler.scrape(
|
|
87
|
-
|
|
87
|
+
url="https://webcrawlerapi.com"
|
|
88
88
|
)
|
|
89
89
|
if response.success:
|
|
90
90
|
print(response.markdown)
|
|
@@ -12,13 +12,15 @@ from .models import (
|
|
|
12
12
|
Action,
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
+
CRAWLER_VERSION = "v1"
|
|
16
|
+
SCRAPER_VERSION = "v2"
|
|
15
17
|
|
|
16
18
|
class WebCrawlerAPI:
|
|
17
19
|
"""Python SDK for WebCrawler API."""
|
|
18
20
|
|
|
19
21
|
DEFAULT_POLL_DELAY_SECONDS = 5
|
|
20
22
|
|
|
21
|
-
def __init__(self, api_key: str, base_url: str = "https://api.webcrawlerapi.com"
|
|
23
|
+
def __init__(self, api_key: str, base_url: str = "https://api.webcrawlerapi.com"):
|
|
22
24
|
"""
|
|
23
25
|
Initialize the WebCrawler API client.
|
|
24
26
|
|
|
@@ -29,7 +31,6 @@ class WebCrawlerAPI:
|
|
|
29
31
|
"""
|
|
30
32
|
self.api_key = api_key
|
|
31
33
|
self.base_url = base_url.rstrip('/')
|
|
32
|
-
self.version = version
|
|
33
34
|
self.session = requests.Session()
|
|
34
35
|
self.session.headers.update({
|
|
35
36
|
'Authorization': f'Bearer {api_key}',
|
|
@@ -86,7 +87,7 @@ class WebCrawlerAPI:
|
|
|
86
87
|
payload["actions"] = [vars(action) for action in action_list]
|
|
87
88
|
|
|
88
89
|
response = self.session.post(
|
|
89
|
-
urljoin(self.base_url, f"/{
|
|
90
|
+
urljoin(self.base_url, f"/{CRAWLER_VERSION}/crawl"),
|
|
90
91
|
json=payload
|
|
91
92
|
)
|
|
92
93
|
response.raise_for_status()
|
|
@@ -106,7 +107,7 @@ class WebCrawlerAPI:
|
|
|
106
107
|
requests.exceptions.RequestException: If the API request fails
|
|
107
108
|
"""
|
|
108
109
|
response = self.session.get(
|
|
109
|
-
urljoin(self.base_url, f"/{
|
|
110
|
+
urljoin(self.base_url, f"/{CRAWLER_VERSION}/job/{job_id}")
|
|
110
111
|
)
|
|
111
112
|
response.raise_for_status()
|
|
112
113
|
return Job(response.json())
|
|
@@ -126,7 +127,7 @@ class WebCrawlerAPI:
|
|
|
126
127
|
requests.exceptions.RequestException: If the API request fails
|
|
127
128
|
"""
|
|
128
129
|
response = self.session.put(
|
|
129
|
-
urljoin(self.base_url, f"/{
|
|
130
|
+
urljoin(self.base_url, f"/{CRAWLER_VERSION}/job/{job_id}/cancel")
|
|
130
131
|
)
|
|
131
132
|
response.raise_for_status()
|
|
132
133
|
return response.json()
|
|
@@ -246,7 +247,7 @@ class WebCrawlerAPI:
|
|
|
246
247
|
payload["actions"] = [vars(action) for action in action_list]
|
|
247
248
|
|
|
248
249
|
response = self.session.post(
|
|
249
|
-
urljoin(self.base_url, f"/{
|
|
250
|
+
urljoin(self.base_url, f"/{SCRAPER_VERSION}/scrape?async=true"),
|
|
250
251
|
json=payload
|
|
251
252
|
)
|
|
252
253
|
|
|
@@ -279,7 +280,7 @@ class WebCrawlerAPI:
|
|
|
279
280
|
requests.exceptions.RequestException: If the API request fails
|
|
280
281
|
"""
|
|
281
282
|
response = self.session.get(
|
|
282
|
-
urljoin(self.base_url, f"/{
|
|
283
|
+
urljoin(self.base_url, f"/{SCRAPER_VERSION}/scrape/{scrape_id}")
|
|
283
284
|
)
|
|
284
285
|
|
|
285
286
|
response.raise_for_status()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: webcrawlerapi
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5
|
|
4
4
|
Summary: Python SDK for WebCrawler API
|
|
5
5
|
Home-page: https://github.com/webcrawlerapi/webcrawlerapi-python-sdk
|
|
6
6
|
Author: Andrew
|
|
@@ -101,11 +101,11 @@ print(f"Cancellation response: {cancel_response['message']}")
|
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
### Scraping
|
|
104
|
-
|
|
104
|
+
Check a working code example of [scraping](https://github.com/WebCrawlerAPI/webcrawlerapi-examples/tree/master/python/scraping) and [scraping with a prompt](https://github.com/WebCrawlerAPI/webcrawlerapi-examples/tree/master/python/scraping_prompt)
|
|
105
105
|
```python
|
|
106
106
|
# Returns structured data directly
|
|
107
107
|
response = crawler.scrape(
|
|
108
|
-
|
|
108
|
+
url="https://webcrawlerapi.com"
|
|
109
109
|
)
|
|
110
110
|
if response.success:
|
|
111
111
|
print(response.markdown)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|