Commit c6a8ab6 2knal
committed
1 parent 602882b commit c6a8ab6 Copy full SHA for c6a8ab6
File tree 5 files changed +18
-12
lines changed
5 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,15 @@ Python package to generate a random proxy on the fly!
19
19
- Fetch elite / transparent / anonymous proxies respectively.
20
20
- Fetch directly from [ free-proxy-list] ( https://free-proxy-list.net ) .
21
21
- For better response time, fetch from an elasticsearch ` cache_server ` .
22
- - ` cache_server ` is updated via routines described [ here] ( ./random_proxies/cache_server /README.md )
22
+ - ` cache_server ` is updated via routines described [ here] ( ./random_proxies/cache /README.md )
23
23
24
24
25
25
## Example usage
26
- <!-- ```bash
27
- pip install random_proxies
26
+
27
+ ``` bash
28
+ pip install random-proxies
28
29
```
29
- or -->
30
+ or
30
31
``` bash
31
32
$ git clone https://github.com/2knal/random_proxies.git`
32
33
$ cd random_proxies/
@@ -40,16 +41,16 @@ Open python interpreter. (Supports version 3.7+)
40
41
' 23.101.2.247:81'
41
42
` ` `
42
43
43
- Refer more examples [here](./examples/)
44
+ Refer more examples [here](./examples/example.py )
44
45
45
46
# # TODO
46
47
47
48
- [x] Port to MongoDB
48
- - [ ] Publish package version 0.0.1
49
+ - [x ] Publish package version 0.0.2
49
50
- [ ] Return meta data, response structure found [here](./random_proxies/cache/README.md)
50
51
- [ ] Scrape proxies from other sources
51
52
- [ ] Add support for SOCKS version 5
52
- - [ ] Implement REST API to allow other languages to interface with it
53
+ - [x ] Implement REST API to allow other languages to interface with it
53
54
- [ ] Setup documentation page
54
55
- [ ] Add unit tests
55
56
Original file line number Diff line number Diff line change 1
1
'''
2
2
(Once the package is published)
3
- pip install random_proxies
3
+ pip install random-proxies
4
4
or
5
5
Follow example usage to import the package
6
6
'''
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def fetch():
22
22
# Fetch from proxies
23
23
proxies = proxies_collection .find (conditions )
24
24
if proxies .count () == 0 :
25
- raise NoSuchProxyError ( 'No proxy satisfying given conditions.' )
25
+ return jsonify ({ 'success' : 'no' } )
26
26
27
27
# Randomly select it
28
28
proxies = list (proxies )
@@ -36,7 +36,7 @@ def fetch():
36
36
# Add it to recents index
37
37
recents_collection .insert_one (proxy )
38
38
39
- return jsonify ({ 'ip' : ip })
39
+ return jsonify ({ 'ip' : ip , 'success' : 'yes' })
40
40
41
41
except Exception as e :
42
42
template = 'An exception of type {0} occurred.\n Arguments: {1!r}'
Original file line number Diff line number Diff line change 3
3
4
4
import json
5
5
import requests
6
+
6
7
from random_proxies .proxies .settings import CACHE_SERVER_URL
8
+ from random_proxies .proxies .exception import NoSuchProxyError
7
9
8
10
def pop (conditions ):
9
11
query_string = '?'
@@ -14,4 +16,7 @@ def pop(conditions):
14
16
data = requests .get (url ).text
15
17
data = json .loads (data )
16
18
17
- return data ['ip' ]
19
+ if data ['success' ] == 'yes' :
20
+ return data ['ip' ]
21
+ else :
22
+ raise NoSuchProxyError ('No proxy satisfying given conditions.' )
Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
2
from __future__ import absolute_import , unicode_literals
3
3
4
- __version__ = '0.0.1 '
4
+ __version__ = '0.0.2 '
5
5
6
6
BASE_URL = 'https://free-proxy-list.net/'
7
7
SSL_URL = 'http://sslproxies.org/'
You can’t perform that action at this time.
0 commit comments