Skip to content

Commit 1faa773

Browse files
authored
Merge pull request #6 from ScrapingAnt/feature/issue4-remove-proxy-country-list
feature/issue4-remove-proxy-country-list
2 parents d4c567d + f51f038 commit 1faa773

File tree

6 files changed

+21
-45
lines changed

6 files changed

+21
-45
lines changed

.github/workflows/code_checks.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ jobs:
77
strategy:
88
matrix:
99
pyver: [ 3.6, 3.7, 3.8, 3.9 ]
10-
no-extensions: [ '', 'Y' ]
1110
os: [ ubuntu, macos, windows ]
1211
fail-fast: true
1312
runs-on: ${{ matrix.os }}-latest

README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# ScrapingAnt API client for Python
2+
[![PyPI version](https://badge.fury.io/py/scrapingant-client.svg)](https://badge.fury.io/py/scrapingant-client)
3+
24
`scrapingant-client` is the official library to access [ScrapingAnt API](https://docs.scrapingant.com) from your
3-
Python applications. It provides useful features like parameters encoding to improve the ScrapingAnt usage experience.
5+
Python applications. It provides useful features like parameters encoding to improve the ScrapingAnt usage experience.
6+
Requires python 3.6+.
47

58
<!-- toc -->
69

@@ -9,6 +12,7 @@ Python applications. It provides useful features like parameters encoding to im
912
- [API Reference](#api-reference)
1013
- [Exceptions](#exceptions)
1114
- [Examples](#examples)
15+
- [Useful links](#useful-links)
1216

1317
<!-- tocstop -->
1418

@@ -28,9 +32,7 @@ In order to get API token you'll need to register at [ScrapingAnt Service](https
2832
## API Reference
2933
All public classes, methods and their parameters can be inspected in this API reference.
3034

31-
<a name="ScrapingAntClient"></a>
32-
33-
#### [](#ScrapingAntClient) ScrapingAntClient(token)
35+
#### ScrapingAntClient(token)
3436

3537
Main class of this library.
3638

@@ -40,7 +42,7 @@ Main class of this library.
4042

4143
* * *
4244

43-
#### [](#ScrapingAntClient+general_request) `ScrapingAntClient.general_request(url, cookies, js_snippet, proxy_country, return_text)` ⇒ Response
45+
#### ScrapingAntClient.general_request
4446

4547
https://docs.scrapingant.com/request-response-format#available-parameters
4648

@@ -49,14 +51,14 @@ https://docs.scrapingant.com/request-response-format#available-parameters
4951
| url | <code>string</code> | |
5052
| cookies | <code>List[Cookie]</code> | None |
5153
| js_snippet | <code>string</code> | None |
52-
| proxy_country | <code>ProxyCountry</code> | None |
54+
| proxy_country | <code>str</code> | None |
5355
| return_text | <code>boolean</code> | False |
5456

5557
**IMPORTANT NOTE:** <code>js_snippet</code> will be encoded to Base64 automatically by the ScrapingAnt client library.
5658

5759
* * *
5860

59-
#### [](#Cookie) Cookie
61+
#### Cookie
6062
Class defining cookie. Curently supports only name and value
6163

6264
| Param | Type |
@@ -66,21 +68,15 @@ Class defining cookie. Curently supports only name and value
6668

6769
* * *
6870

69-
#### [](#ProxyCountry) ProxyCountry
70-
71-
Enum containing all available proxy countries
72-
73-
* * *
74-
75-
#### [](#Response) Response
76-
Class defining cookie. Curently supports only name and value
71+
#### Response
72+
Class defining response from API.
7773

7874
| Param | Type |
7975
| --- | --- |
8076
| content | <code>string</code> |
8177
| cookies | <code>List[Cookie]</code> |
8278

83-
## [](#exceptions) Exceptions
79+
## Exceptions
8480

8581
`ScrapingantClientException` is base Exception class, used for all errors.
8682

@@ -131,4 +127,8 @@ result = client.general_request(
131127
js_snippet=customJsSnippet,
132128
)
133129
print(result.content)
134-
```
130+
```
131+
132+
## Useful links
133+
- [Scrapingant Api doumentation](https://docs.scrapingant.com)
134+
- [Scrapingant Js Client](https://github.com/scrapingant/scrapingant-client-js)

scrapingant_client/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from scrapingant_client.client import ScrapingAntClient
2-
from scrapingant_client.constants import ProxyCountry
32
from scrapingant_client.cookie import Cookie
43
from scrapingant_client.errors import (
54
ScrapingantClientException,
@@ -11,7 +10,6 @@
1110

1211
__all__ = [
1312
'ScrapingAntClient',
14-
'ProxyCountry',
1513
'Cookie',
1614
'ScrapingantClientException',
1715
'ScrapingantInvalidTokenException',

scrapingant_client/client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import requests
66

7-
from scrapingant_client.constants import ProxyCountry, SCRAPINGANT_API_BASE_URL
7+
from scrapingant_client.constants import SCRAPINGANT_API_BASE_URL
88
from scrapingant_client.cookie import Cookie, cookies_list_to_string, cookies_list_from_string
99
from scrapingant_client.errors import (
1010
ScrapingantInvalidTokenException,
@@ -30,7 +30,7 @@ def general_request(
3030
url: str,
3131
cookies: Optional[List[Cookie]] = None,
3232
js_snippet: Optional[str] = None,
33-
proxy_country: Optional[ProxyCountry] = None,
33+
proxy_country: Optional[str] = None,
3434
return_text: bool = False,
3535
) -> Response:
3636
request_data = {'url': url}
@@ -39,7 +39,7 @@ def general_request(
3939
if js_snippet is not None:
4040
encoded_js_snippet = base64_encode_string(js_snippet)
4141
request_data['js_snippet'] = encoded_js_snippet
42-
if proxy_country:
42+
if proxy_country is not None:
4343
request_data['proxy_country'] = proxy_country.lower()
4444
if return_text:
4545
request_data['return_text'] = True

scrapingant_client/constants.py

-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
1-
from enum import Enum
2-
31
SCRAPINGANT_API_BASE_URL = 'https://api.scrapingant.com/v1'
4-
5-
6-
class ProxyCountry(str, Enum):
7-
brasilia = 'br'
8-
china = 'cn'
9-
germany = 'de'
10-
spain = 'es'
11-
france = 'fr'
12-
the_united_kingdom = 'gb'
13-
hong_kong = 'hk'
14-
india = 'in'
15-
italy = 'it'
16-
israel = 'il'
17-
japan = 'jp'
18-
the_netherlands = 'nl'
19-
russia = 'ru'
20-
saudi_arabia = 'sa'
21-
the_united_arab_emirates = 'ae'
22-
usa = 'us'

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="scrapingant-client",
8-
version="0.2.0",
8+
version="0.3.0",
99
author="andrii.kovalenko",
1010
author_email="[email protected]",
1111
license='Apache-2.0',

0 commit comments

Comments
 (0)