-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathproxy.py
More file actions
36 lines (30 loc) · 839 Bytes
/
proxy.py
File metadata and controls
36 lines (30 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from attr import attrs, attr
@attrs
class Proxy(object):
"""
proxy schema
"""
host = attr(type=str, default=None)
port = attr(type=int, default=None)
location = attr(type=str, default=None)
isp = attr(type=str, default=None)
country = attr(type=str, default=None)
anonymous = attr(type=bool, default=None)
protocol = attr(type=str, default=None)
alive_time = attr(type=int, default=None)
def __str__(self):
"""
to string, for print
:return:
"""
return f'{self.host}:{self.port}'
def string(self):
"""
to string
:return: <host>:<port>
"""
return self.__str__()
if __name__ == '__main__':
proxy = Proxy(host='8.8.8.8', port=8888)
print('proxy', proxy)
print('proxy', proxy.string())