Skip to content

Commit 227d582

Browse files
authored
Update README.md
1 parent 1c14156 commit 227d582

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

README.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ rt.head(url, **kwargs)
142142
cert – (optional) if String, path to ssl client cert file (.pem).
143143
If Tuple, (‘cert’, ‘key’) pair.
144144
"""
145+
```
146+
## Examples
147+
### 1. Get url with unique params and headers in request.
148+
```python
149+
from requests_tor import RequestsTor
150+
151+
rt = RequestsTor(tor_ports=(9000, 9001, 9002, 9003, 9004), autochange_id=5)
145152

146153
url = 'https://httpbin.org/anything'
147154
params = {
@@ -154,6 +161,13 @@ headers = {
154161
}
155162
r = rt.get(url, params=params, headers=headers)
156163
print(r.text)
164+
```
165+
166+
### 2. Get list of urls concurrently.
167+
```python
168+
from requests_tor import RequestsTor
169+
170+
rt = RequestsTor(tor_ports=(9000, 9001, 9002, 9003, 9004), autochange_id=5)
157171

158172
# get urls list concurrently. TOR new identity is executed depending on the number of socksports and
159173
# autochange_id parameter. In case of 5 socksports and autochange_id=5, after downloading 5*5=25 urls
@@ -163,18 +177,16 @@ urls = (f'https://checkip.amazonaws.com' for _ in range(10))
163177
results = rt.get_urls(urls)
164178
for r in results:
165179
print(r.text)
180+
```
166181

167-
168-
```
169-
### Example: downloading list of urls concurrently with unique ip for each url
170-
Urls: https://habr.com/ru/post/1 - https://habr.com/ru/post/50
171-
182+
183+
### 3. Get list of urls concurrently with unique ip for each url
172184
```python
173185
from requests_tor import RequestsTor
174186

175187
rt = RequestsTor(tor_ports=(9000, 9001, 9002, 9003, 9004), autochange_id=1)
176188

177-
urls = (f'https://habr.com/ru/post/{x}' for x in range(1, 50))
189+
urls = (f'https://habr.com/ru/post/{x}' for x in range(1, 51))
178190
r = rt.get_urls(urls)
179191
print(r[-1].text)
180192
```

0 commit comments

Comments
 (0)