Skip to content

Commit 2a4b999

Browse files
author
Two Dev
committed
chore: docs
1 parent 9085e55 commit 2a4b999

File tree

9 files changed

+32
-45
lines changed

9 files changed

+32
-45
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ it combines ease of use with advanced functionality for secure networking.
5757

5858
Modern websites increasingly use **TLS Fingerprinting** and anti-bot tools like Cloudflare Bot Fight Mode to block web crawlers.
5959

60-
**TLS Requests** bypasses these obstacles by mimicking browser-like TLS behaviors,
60+
**TLS Requests** bypass these obstacles by mimicking browser-like TLS behaviors,
6161
making it easy to scrape data or interact with websites that use sophisticated anti-bot measures.
6262

63-
### Example: Unlocking Cloudflare Bot Fight Mode
63+
### Unlocking Cloudflare Bot Fight Mode
6464
![coingecko.png](https://raw.githubusercontent.com/thewebscraping/tls-requests/refs/heads/main/docs/static/coingecko.png)
6565

6666
**Example Code:**

docs/tls/index.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ TLS-Client Documentation
22
========================
33

44
**Acknowledgment**
5+
56
Special thanks to [`bogdanfinn`](https://github.com/bogdanfinn/tls-client). For more details, visit the [GitHub repository](https://github.com/bogdanfinn/tls-client) or explore the [documentation](https://bogdanfinn.gitbook.io/open-source-oasis).
67

78
## Wrapper TLS Client
@@ -15,8 +16,6 @@ The TLSClient class is designed to be used as a singleton-like interface. Upon f
1516
>>> TLSClient.initialize()
1617
```
1718

18-
![load_library.png](../static/load_library.png)
19-
2019
!!! note
2120
The first time you initialize the TLSClient class, it will automatically find and load the appropriate library for your machine.
2221

docs/tls/install.md

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
## Auto Download
22

3-
No additional steps are required! Simply use the Python syntax below, and the library will automatically detect and download the version compatible with your operating system by fetching it from the GitHub repository.
4-
5-
#### Reference: [GitHub Releases - TLS Client](https://github.com/bogdanfinn/tls-client/releases/)
6-
7-
The downloaded library files are stored in the `tls_requests/bin` directory.
3+
This approach simplifies usage as it automatically detects your OS and downloads the appropriate version of the library. To use it:
84

95
```pycon
10-
>>> from src import tls_requests
6+
>>> import tls_requests
117
>>> r = tls_requests.get('https://httpbin.org/get')
128
```
139

14-
## Manual Download
10+
!!! note:
11+
The library takes care of downloading necessary files and stores them in the `tls_requests/bin` directory.
1512

16-
For manual installation, you can download the library using the following script:
13+
## Manual Download
1714

18-
```python
19-
from tls_requests.models.libraries import TLSLibrary
15+
If you want more control, such as selecting a specific version of the library, you can use the manual method:
2016

21-
TLSLibrary.load()
22-
# OR: TLSLibrary.download()
17+
```pycon
18+
>>> from tls_requests.models.libraries import TLSLibrary
19+
>>> TLSLibrary.download('1.7.10')
2320
```
21+
22+
This method is useful if you need to ensure compatibility with specific library versions.
23+
24+
### Notes
25+
26+
1. **Dependencies**: Ensure Python is installed and configured correctly in your environment.
27+
2. **Custom Directory**: If needed, the library’s downloaded binaries can be relocated manually to suit specific project structures.
28+
3. **Reference**: [TLS Client GitHub Releases](https://github.com/bogdanfinn/tls-client/releases/) provides details about available versions and updates.

requirements.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Base
2+
chardet~=5.2.0
3+
requests~=2.32.3
4+
tqdm~=4.67.1
5+
16
# Documentation
27
mkdocs==1.6.1
38
mkautodoc==0.2.0

setup.cfg

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ long_description_content_type = text/markdown
44
license = MIT
55
license_file = LICENSE
66
python_requires = >=3.9
7+
install_requires =
8+
chardet ~= 5.2.0
9+
requests ~= 2.32.3
10+
tqdm ~= 4.67.1
711
classifiers =
812
Development Status :: 5 - Production/Stable
913
Intended Audience :: Developers

tls_requests/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
__url__ = "https://github.com/thewebscraping/tls-requests"
44
__author__ = "Tu Pham"
55
__author_email__ = "[email protected]"
6-
__version__ = "1.0.1"
6+
__version__ = "1.0.2"
77
__license__ = "MIT"

tls_requests/models/libraries.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ def find_all(cls) -> list[str]:
9494
return glob.glob(os.path.join(BIN_DIR, r"*"))
9595

9696
@classmethod
97-
def download(cls) -> str:
97+
def download(cls, version: str = None) -> str:
9898
try:
9999
download_url = None
100-
for download_url in cls.fetch_api():
100+
for download_url in cls.fetch_api(version):
101101
if PATTERN_RE.search(download_url):
102102
break
103103

104-
print(download_url)
105104
if download_url:
106105
destination = os.path.join(BIN_DIR, download_url.split("/")[-1])
107106
with requests.get(download_url, stream=True) as response:

tls_requests/models/response.py

-10
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,6 @@ def json(self, **kwargs: Any) -> Any:
207207
def __repr__(self) -> str:
208208
return f"<Response [{self.status_code}]>"
209209

210-
def __getstate__(self) -> dict[str, Any]:
211-
return {
212-
name: value
213-
for name, value in self.__dict__.items()
214-
if name not in ["stream", "is_closed"]
215-
}
216-
217-
def __setstate__(self, state: dict[str, Any]) -> None:
218-
pass
219-
220210
def read(self) -> bytes:
221211
with self.stream as stream:
222212
self._content = b"".join(stream.render())

tls_requests/utils.py

-15
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ def get_logger(
4040
return logger
4141

4242

43-
def primitive_value_to_str(value) -> str:
44-
"""
45-
Coerce a primitive data type into a string value.
46-
47-
Note that we prefer JSON-style 'true'/'false' for boolean values here.
48-
"""
49-
if value is True:
50-
return "true"
51-
elif value is False:
52-
return "false"
53-
elif value is None:
54-
return ""
55-
return str(value)
56-
57-
5843
def to_bytes(value: Any, encoding: str = "utf-8", *, lower: bool = False) -> bytes:
5944
if isinstance(value, (bytes, bytearray)):
6045
return value

0 commit comments

Comments
 (0)