forked from awolfly9/IPProxyTool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
proxy.py
85 lines (73 loc) · 2.66 KB
/
proxy.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf-8 -*-
class Proxy(object):
def __init__(self):
self.id = 1
self.ip = ''
self.port = ''
self.country = ''
self.anonymity = ''
self.https = ''
self.speed = ''
self.source = ''
self.vali_count = 0
def __str__(self):
data = {
'ip': self.ip,
'port': self.port,
'country': self.country,
'anonymity': self.anonymity,
'https': self.https,
'speed': self.speed,
'source': self.source,
'vali_count': self.vali_count,
}
return str(data)
def __dict__(self):
data = {
'ip': self.ip,
'port': self.port,
'country': self.country,
'anonymity': self.anonymity,
'https': self.https,
'speed': self.speed,
'source': self.source,
'vali_count': self.vali_count,
}
return data
def get_dict(self):
data = {
'ip': self.ip,
'port': self.port,
'country': self.country,
'anonymity': self.anonymity,
'https': self.https,
'speed': self.speed,
'source': self.source,
'vali_count': self.vali_count,
}
return data
def set_value(self, ip, port, country, anonymity, source='unkonw', https='no', speed=-1, vali_count=0):
self.ip = ip
self.port = port
self.country = country
self.anonymity = self.get_anonymity_type(anonymity)
self.https = https
self.speed = speed
self.source = source
self.vali_count = vali_count
def get_anonymity_type(self, anonymity):
'''There are 3 levels of proxies according to their anonymity.
Level 1 - Elite Proxy / Highly Anonymous Proxy: The web server can't detect whether you are using a proxy.
Level 2 - Anonymous Proxy: The web server can know you are using a proxy, but it can't know your real IP.
Level 3 - Transparent Proxy: The web server can know you are using a proxy and it can also know your real
IP.
'''
if anonymity == u'高匿代理' or anonymity == u'高匿名' or anonymity == 'elite proxy' or \
anonymity == u'超级匿名' or anonymity == u'High':
return '1'
elif anonymity == u'匿名' or anonymity == 'anonymous' or anonymity == u'普通匿名' or anonymity == u'Medium':
return '2'
elif anonymity == u'透明' or anonymity == 'transparent' or anonymity == u'No':
return '3'
else:
return '3'