@@ -142,6 +142,13 @@ rt.head(url, **kwargs)
142
142
cert – (optional) if String, path to ssl client cert file (.pem).
143
143
If Tuple, (‘cert’, ‘key’) pair.
144
144
"""
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 )
145
152
146
153
url = ' https://httpbin.org/anything'
147
154
params = {
@@ -154,6 +161,13 @@ headers = {
154
161
}
155
162
r = rt.get(url, params = params, headers = headers)
156
163
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 )
157
171
158
172
# get urls list concurrently. TOR new identity is executed depending on the number of socksports and
159
173
# 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))
163
177
results = rt.get_urls(urls)
164
178
for r in results:
165
179
print (r.text)
180
+ ```
166
181
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
172
184
``` python
173
185
from requests_tor import RequestsTor
174
186
175
187
rt = RequestsTor(tor_ports = (9000 , 9001 , 9002 , 9003 , 9004 ), autochange_id = 1 )
176
188
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 ))
178
190
r = rt.get_urls(urls)
179
191
print (r[- 1 ].text)
180
192
```
0 commit comments