@@ -22,37 +22,43 @@ How to install?
22
22
23
23
There is a prepared docker image.
24
24
25
- 1 Install docker. If you're using ubuntu:
25
+ 1 Install docker and docker compose . If you're using ubuntu:
26
26
27
27
.. code-block :: bash
28
28
29
- sudo apt install docker.io
29
+ sudo apt install docker.io docker-compose
30
+
31
+ 2 Download docker compose config:
32
+
33
+ .. code-block :: bash
34
+
35
+ wget " https://raw.githubusercontent.com/DevAlone/proxy_py/master/docker-compose.yml"
30
36
31
37
2 Create a container
32
38
33
39
.. code-block :: bash
34
40
35
- docker create -p 55555:55555 --name proxy_py devalone/proxy_py:v2.2
41
+ docker-compose build
36
42
37
43
3 Run
38
44
39
45
.. code-block ::
40
46
41
- docker start proxy_py
47
+ docker-compose up
42
48
43
49
It will give you a server on address localhost:55555
44
50
45
51
To see running containers use
46
52
47
53
.. code-block :: bash
48
54
49
- docker ps
55
+ docker-compose ps
50
56
51
57
To stop proxy_py use
52
58
53
59
.. code-block :: bash
54
60
55
- docker stop proxy_py
61
+ docker-compose stop
56
62
57
63
How to get proxies?
58
64
*******************
@@ -65,11 +71,11 @@ on address `http://127.0.0.1:55555/api/v1/`
65
71
66
72
.. code-block :: json
67
73
68
- {
69
- "model" : " proxy" ,
70
- "method" : " get" ,
71
- "order_by" : " response_time, uptime"
72
- }
74
+ {
75
+ "model": "proxy",
76
+ "method": "get",
77
+ "order_by": "response_time, uptime"
78
+ }
73
79
74
80
Note: order_by makes the result sorted
75
81
by one or more fields(separated by comma).
@@ -80,25 +86,25 @@ It's gonna return you the json response like this:
80
86
81
87
.. code-block :: json
82
88
83
- {
84
- "count" : 1 ,
85
- "data" : [{
86
- "address" : " http://127.0.0.1:8080" ,
87
- "auth_data" : " " ,
88
- "bad_proxy" : false ,
89
- "domain" : " 127.0.0.1" ,
90
- "last_check_time" : 1509466165 ,
91
- "number_of_bad_checks" : 0 ,
92
- "port" : 8080 ,
93
- "protocol" : " http" ,
94
- "response_time" : 461691 ,
95
- "uptime" : 1509460949
96
- }
97
- ],
98
- "has_more" : false ,
99
- "status" : " ok" ,
100
- "status_code" : 200
101
- }
89
+ {
90
+ "count": 1,
91
+ "data": [{
92
+ "address": "http://127.0.0.1:8080",
93
+ "auth_data": "",
94
+ "bad_proxy": false,
95
+ "domain": "127.0.0.1",
96
+ "last_check_time": 1509466165,
97
+ "number_of_bad_checks": 0,
98
+ "port": 8080,
99
+ "protocol": "http",
100
+ "response_time": 461691,
101
+ "uptime": 1509460949
102
+ }
103
+ ],
104
+ "has_more": false,
105
+ "status": "ok",
106
+ "status_code": 200
107
+ }
102
108
103
109
Note: All fields except *protocol *, *domain *, *port *, *auth_data *,
104
110
*checking_period * and *address * CAN be null
@@ -107,80 +113,80 @@ Or error if something went wrong:
107
113
108
114
.. code-block :: json
109
115
110
- {
111
- "error_message" : " You should specify \" model\" " ,
112
- "status" : " error" ,
113
- "status_code" : 400
114
- }
116
+ {
117
+ "error_message": "You should specify \" model\" ",
118
+ "status": "error",
119
+ "status_code": 400
120
+ }
115
121
116
122
Note: status_code is also duplicated in HTTP status code
117
123
118
124
Example using curl:
119
125
120
126
.. code-block :: bash
121
127
122
- curl -X POST http://127.0.0.1:55555/api/v1/ -H " Content-Type: application/json" --data ' {"model": "proxy", "method": "get"}'
128
+ curl -X POST http://127.0.0.1:55555/api/v1/ -H "Content-Type: application/json" --data '{"model": "proxy", "method": "get"}'
123
129
124
130
Example using httpie:
125
131
126
132
.. code-block :: bash
127
133
128
- http POST http://127.0.0.1:55555/api/v1/ model=proxy method=get
134
+ http POST http://127.0.0.1:55555/api/v1/ model=proxy method=get
129
135
130
136
Example using python's *requests * library:
131
137
132
138
.. code-block :: python
133
139
134
- import requests
135
- import json
140
+ import requests
141
+ import json
136
142
137
143
138
- def get_proxies ():
139
- result = []
140
- json_data = {
141
- " model" : " proxy" ,
142
- " method" : " get" ,
143
- }
144
- url = " http://127.0.0.1:55555/api/v1/"
144
+ def get_proxies():
145
+ result = []
146
+ json_data = {
147
+ "model": "proxy",
148
+ "method": "get",
149
+ }
150
+ url = "http://127.0.0.1:55555/api/v1/"
145
151
146
- response = requests.post(url, json = json_data)
147
- if response.status_code == 200 :
148
- response = json.loads(response.text)
149
- for proxy in response[" data" ]:
150
- result.append(proxy[" address" ])
151
- else :
152
- # check error here
153
- pass
152
+ response = requests.post(url, json=json_data)
153
+ if response.status_code == 200:
154
+ response = json.loads(response.text)
155
+ for proxy in response["data"]:
156
+ result.append(proxy["address"])
157
+ else:
158
+ # check error here
159
+ pass
154
160
155
- return result
161
+ return result
156
162
157
163
Example using aiohttp library:
158
164
159
165
.. code-block :: python
160
166
161
- import aiohttp
167
+ import aiohttp
162
168
163
169
164
- async def get_proxies ():
165
- result = []
166
- json_data = {
167
- " model" : " proxy" ,
168
- " method" : " get" ,
169
- }
170
+ async def get_proxies():
171
+ result = []
172
+ json_data = {
173
+ "model": "proxy",
174
+ "method": "get",
175
+ }
170
176
171
- url = " http://127.0.0.1:55555/api/v1/"
177
+ url = "http://127.0.0.1:55555/api/v1/"
172
178
173
- async with aiohttp.ClientSession() as session:
174
- async with session.post(url, json = json_data) as response:
175
- if response.status == 200 :
176
- response = json.loads(await response.text())
177
- for proxy in response[" data" ]:
178
- result.append(proxy[" address" ])
179
- else :
180
- # check error here
181
- pass
179
+ async with aiohttp.ClientSession() as session:
180
+ async with session.post(url, json=json_data) as response:
181
+ if response.status == 200:
182
+ response = json.loads(await response.text())
183
+ for proxy in response["data"]:
184
+ result.append(proxy["address"])
185
+ else:
186
+ # check error here
187
+ pass
182
188
183
- return result
189
+ return result
184
190
185
191
How to interact with API?
186
192
*************************
@@ -193,53 +199,53 @@ What about WEB interface?
193
199
There is lib.ru inspired web interface which consists of these pages(with slash at the end):
194
200
195
201
- http://localhost:55555/i/get/proxy/
196
- - http://localhost:55555/i/get/proxy_count_item/
197
- - http://localhost:55555/i/get/number_of_proxies_to_process/
198
- - http://localhost:55555/i/get/collector_state/
202
+ - http://localhost:55555/i/get/proxy_count_item/
203
+ - http://localhost:55555/i/get/number_of_proxies_to_process/
204
+ - http://localhost:55555/i/get/collector_state/
199
205
200
- How to contribute?
201
- ******************
206
+ How to contribute?
207
+ **************** **
202
208
203
- Just fork, do your changes(implement new collector, fix a bug
204
- or whatever you want) and create pull request.
209
+ Just fork, do your changes(implement new collector, fix a bug
210
+ or whatever you want) and create pull request.
205
211
206
- Here are some useful guides:
212
+ Here are some useful guides:
207
213
208
- `How to create a collector <https://proxy-py.readthedocs.io/en/latest/guides/how_to_create_collector.html >`_
214
+ `How to create a collector <https://proxy-py.readthedocs.io/en/latest/guides/how_to_create_collector.html >`_
209
215
210
- How to test it?
211
- ***************
216
+ How to test it?
217
+ ************* **
212
218
213
- If you've made changes to the code and want to check that you didn't break
214
- anything, just run
219
+ If you've made changes to the code and want to check that you didn't break
220
+ anything, just run
215
221
216
- .. code-block :: bash
222
+ .. code-block :: bash
217
223
218
- py.test
224
+ py.test
219
225
220
- inside virtual environment in proxy_py project directory.
226
+ inside virtual environment in proxy_py project directory.
221
227
222
- How to build from scratch?
223
- **************************
228
+ How to build from scratch?
229
+ ************************ **
224
230
225
- 1 Clone this repository
231
+ 1 Clone this repository
226
232
227
- .. code-block :: bash
233
+ .. code-block :: bash
228
234
229
- git clone https://github.com/DevAlone/proxy_py.git
235
+ git clone https://github.com/DevAlone/proxy_py.git
230
236
231
237
2 Install requirements
232
238
233
239
.. code-block :: bash
234
240
235
- cd proxy_py
236
- pip3 install -r requirements.txt
241
+ cd proxy_py
242
+ pip3 install -r requirements.txt
237
243
238
244
3 Create settings file
239
245
240
246
.. code-block :: bash
241
247
242
- cp config_examples/settings.py proxy_py/settings.py
248
+ cp config_examples/settings.py proxy_py/settings.py
243
249
244
250
4 Install postgresql and change database configuration in settings.py file
245
251
@@ -248,7 +254,7 @@ How to build from scratch?
248
254
6 Run your application
249
255
250
256
.. code-block :: bash
251
- python3 main.py
257
+ python3 main.py
252
258
253
259
7 Enjoy!
254
260
@@ -257,5 +263,5 @@ Mirrors
257
263
*******
258
264
259
265
* https://github.com/DevAlone/proxy_py
260
- * https://gitlab.com/DevAlone/proxy_py
261
- * https://bitbucket.org/d3dev/proxy_py
266
+ * https://gitlab.com/DevAlone/proxy_py
267
+ * https://bitbucket.org/d3dev/proxy_py
0 commit comments