cfcrawler 0.0.1__tar.gz → 0.0.2__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.
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/PKG-INFO +2 -4
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/cfcrawler/cipher.py +3 -1
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/cfcrawler/client.py +3 -3
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/cfcrawler/transport.py +3 -2
- cfcrawler-0.0.2/cfcrawler/types.py +68 -0
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/pyproject.toml +3 -3
- cfcrawler-0.0.1/cfcrawler/types.py +0 -34
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/LICENSE +0 -0
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/README.md +0 -0
- {cfcrawler-0.0.1 → cfcrawler-0.0.2}/cfcrawler/__init__.py +0 -0
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cfcrawler
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Cloudflare scraper and cralwer written in Async
|
|
5
5
|
Home-page: https://github.com/ManiMozaffar/cfcrawler
|
|
6
6
|
Author: Mani Mozaffar
|
|
7
7
|
Author-email: fmani.mozaffar@gmail.com
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.9
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
14
|
Requires-Dist: fake-useragent (>=1.4.0,<2.0.0)
|
|
16
15
|
Requires-Dist: httpx (>=0.25.2,<0.26.0)
|
|
17
|
-
Requires-Dist: pytest-asyncio (>=0.21.1,<0.22.0)
|
|
18
16
|
Project-URL: Documentation, https://ManiMozaffar.github.io/cfcrawler/
|
|
19
17
|
Project-URL: Repository, https://github.com/ManiMozaffar/cfcrawler
|
|
20
18
|
Description-Content-Type: text/markdown
|
|
@@ -22,8 +22,8 @@ class AsyncClient(_AsyncClient):
|
|
|
22
22
|
def __init__(
|
|
23
23
|
self,
|
|
24
24
|
*,
|
|
25
|
-
browser: Browser
|
|
26
|
-
default_user_agent: str
|
|
25
|
+
browser: typing.Optional[Browser] = None,
|
|
26
|
+
default_user_agent: typing.Optional[str] = None,
|
|
27
27
|
auth: typing.Optional[_types.AuthTypes] = None,
|
|
28
28
|
cipher_suite: typing.Optional[str] = None,
|
|
29
29
|
ecdh_curve: typing.Optional[str] = None,
|
|
@@ -52,7 +52,7 @@ class AsyncClient(_AsyncClient):
|
|
|
52
52
|
self.browser: Browser = browser or random.choice(
|
|
53
53
|
[Browser.CHROME, Browser.FIREFOX]
|
|
54
54
|
)
|
|
55
|
-
self.ua = FakeUserAgent(self.browser.value
|
|
55
|
+
self.ua = FakeUserAgent(self.browser.value)
|
|
56
56
|
transport = CfScrapeTransport(
|
|
57
57
|
browser=self.browser, cipher_suite=cipher_suite, ecdh_curve=ecdh_curve
|
|
58
58
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ssl
|
|
2
|
+
import typing
|
|
2
3
|
|
|
3
4
|
from httpx import AsyncHTTPTransport
|
|
4
5
|
|
|
@@ -10,8 +11,8 @@ class CfScrapeTransport(AsyncHTTPTransport):
|
|
|
10
11
|
def __init__(
|
|
11
12
|
self,
|
|
12
13
|
browser: Browser,
|
|
13
|
-
ecdh_curve: str
|
|
14
|
-
cipher_suite: str
|
|
14
|
+
ecdh_curve: typing.Optional[str] = None,
|
|
15
|
+
cipher_suite: typing.Optional[str] = None,
|
|
15
16
|
*args,
|
|
16
17
|
**kwargs,
|
|
17
18
|
) -> None:
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from enum import Enum, auto
|
|
2
|
+
|
|
3
|
+
from typing_extensions import DefaultDict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StrEnum(str, Enum):
|
|
7
|
+
"""
|
|
8
|
+
Enum where members are also (and must be) strings
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __new__(cls, *values):
|
|
12
|
+
"values must already be of type `str`"
|
|
13
|
+
if len(values) > 3:
|
|
14
|
+
raise TypeError("too many arguments for str(): %r" % (values,))
|
|
15
|
+
if len(values) == 1:
|
|
16
|
+
# it must be a string
|
|
17
|
+
if not isinstance(values[0], str):
|
|
18
|
+
raise TypeError("%r is not a string" % (values[0],))
|
|
19
|
+
if len(values) >= 2:
|
|
20
|
+
# check that encoding argument is a string
|
|
21
|
+
if not isinstance(values[1], str):
|
|
22
|
+
raise TypeError("encoding must be a string, not %r" % (values[1],))
|
|
23
|
+
if len(values) == 3:
|
|
24
|
+
# check that errors argument is a string
|
|
25
|
+
if not isinstance(values[2], str):
|
|
26
|
+
raise TypeError("errors must be a string, not %r" % (values[2]))
|
|
27
|
+
value = str(*values)
|
|
28
|
+
member = str.__new__(cls, value)
|
|
29
|
+
member._value_ = value
|
|
30
|
+
return member
|
|
31
|
+
|
|
32
|
+
def _generate_next_value_(name, start, count, last_values):
|
|
33
|
+
"""
|
|
34
|
+
Return the lower-cased version of the member name.
|
|
35
|
+
"""
|
|
36
|
+
return name.lower()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ChallengeStatus(StrEnum):
|
|
40
|
+
PASSED = auto() # dummy value representing a successful attempt
|
|
41
|
+
H_CAPTCHA_V1 = auto()
|
|
42
|
+
H_CAPTCHA_V2 = auto()
|
|
43
|
+
RECAPTCHA = auto()
|
|
44
|
+
IUAM_V1 = auto()
|
|
45
|
+
IUAM_V2 = auto()
|
|
46
|
+
FIREWALL_BLOCKED = auto()
|
|
47
|
+
|
|
48
|
+
UNKNOWN = auto()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class CaptchaTypes(StrEnum):
|
|
52
|
+
RE_CAPTCHA = auto()
|
|
53
|
+
H_CAPTCHA = auto()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ChallengeForm(DefaultDict):
|
|
57
|
+
form: str
|
|
58
|
+
challengeUUID: str
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class CaptchaResult(DefaultDict):
|
|
62
|
+
url: str
|
|
63
|
+
data: dict
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class Browser(StrEnum):
|
|
67
|
+
CHROME = auto()
|
|
68
|
+
FIREFOX = auto()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "cfcrawler"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.2"
|
|
4
4
|
description = "Cloudflare scraper and cralwer written in Async"
|
|
5
5
|
authors = ["Mani Mozaffar <fmani.mozaffar@gmail.com>"]
|
|
6
6
|
repository = "https://github.com/ManiMozaffar/cfcrawler"
|
|
@@ -9,12 +9,12 @@ readme = "README.md"
|
|
|
9
9
|
packages = [{ include = "cfcrawler" }]
|
|
10
10
|
|
|
11
11
|
[tool.poetry.dependencies]
|
|
12
|
-
python = ">=3.
|
|
12
|
+
python = ">=3.9,<4.0"
|
|
13
13
|
fake-useragent = "^1.4.0"
|
|
14
14
|
httpx = "^0.25.2"
|
|
15
|
-
pytest-asyncio = "^0.21.1"
|
|
16
15
|
|
|
17
16
|
[tool.poetry.group.dev.dependencies]
|
|
17
|
+
pytest-asyncio = "^0.21.1"
|
|
18
18
|
pytest = "^7.2.0"
|
|
19
19
|
pytest-cov = "^4.0.0"
|
|
20
20
|
mypy = "^1.5.1"
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from enum import StrEnum, auto
|
|
2
|
-
from typing import DefaultDict
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ChallengeStatus(StrEnum):
|
|
6
|
-
PASSED = auto() # dummy value representing a successful attempt
|
|
7
|
-
H_CAPTCHA_V1 = auto()
|
|
8
|
-
H_CAPTCHA_V2 = auto()
|
|
9
|
-
RECAPTCHA = auto()
|
|
10
|
-
IUAM_V1 = auto()
|
|
11
|
-
IUAM_V2 = auto()
|
|
12
|
-
FIREWALL_BLOCKED = auto()
|
|
13
|
-
|
|
14
|
-
UNKNOWN = auto()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class CaptchaTypes(StrEnum):
|
|
18
|
-
RE_CAPTCHA = auto()
|
|
19
|
-
H_CAPTCHA = auto()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class ChallengeForm(DefaultDict):
|
|
23
|
-
form: str
|
|
24
|
-
challengeUUID: str
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class CaptchaResult(DefaultDict):
|
|
28
|
-
url: str
|
|
29
|
-
data: dict
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class Browser(StrEnum):
|
|
33
|
-
CHROME = auto()
|
|
34
|
-
FIREFOX = auto()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|