-
Notifications
You must be signed in to change notification settings - Fork 11
/
proxyLoader.py
148 lines (127 loc) · 4.25 KB
/
proxyLoader.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import requests
from bs4 import BeautifulSoup
from OpenSSL import SSL
from termcolor import cprint
import json
import re
def filterConnections(proxiesList):
workingProxies = []
count = 0
for proxy in proxiesList:
count += 1
cprint("Loading proxy # {}".format(count), "green")
proxies = {
'http': proxy,
'https': proxy
}
try:
r = requests.get("http://www.supremenewyork.com/shop/all", proxies=proxies, timeout=1)
data = r.text
soup = BeautifulSoup(data,"html.parser")
headerCheck = str(soup.find("span",{"id":"time-zone-name"}).text)
if headerCheck == "NYC":
cprint(headerCheck, "blue")
workingProxies.append(proxy)
cprint("Added {}!".format(proxy),"green")
else:
cprint("Banned!", "red")
raise
except:
cprint("Bad Proxy: {}".format(proxy), "red")
return workingProxies
def site1(proxiesList):
url = "http://www.aliveproxy.com/fastest-proxies/"
user = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"}
r = requests.get(url,headers=user)
data = r.text
soup = BeautifulSoup(data,"html.parser")
for ips in soup.find_all("tr",{"class":"cw-list"}):
for ip in ips.find_all("td",{"class":"dt-tb2"}):
print(ip)
break;
def site2(proxiesList):
url = "https://www.us-proxy.org/"
user = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"}
r = requests.get(url,headers=user)
data = r.text
soup = BeautifulSoup(data,"html.parser")
table = soup.find("tbody")
for ips in table.find_all("tr"):
count = 0
proxy = ""
for ip in ips.find_all("td"):
if count == 0:
proxy = str(ip.text)
proxy += ":"
if count == 1:
proxy += str(ip.text)
proxiesList.append(proxy)
break;
count += 1
cprint("Succesfully added {} proxies!".format(len(proxiesList)), 'green')
def site3(proxiesList):
url = "http://spys.ru/free-proxy-list/US/"
user = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"}
r = requests.post(url,headers=user, data={"xpp":"1"})
data = r.text
soup = BeautifulSoup(data,"html.parser")
proxy = ""
regexProxy = "^.*(?=(document.write))"
# for ips in soup.find_all("tr",{"class":"spy1xx"}):
for ips in soup.find_all("tr"):
count = 0
for ip in ips.find_all("td",{"colspan":"1"}):
# IP
if count == 0:
# rawProxy = str(ip.text)[2:20]
proxy = str(re.sub('[a-z]','', str(ip.text)[2:20])).replace(" ","")
if len(proxy) < 9:
break;
# Type:
if count == 1:
proxyType = str(ip.text)
if "Squid" in proxyType:
proxy += ":3128"
elif "HTTPS" in proxyType:
proxy += ":8080"
elif "HTTP" in proxyType:
proxy += ":80"
elif "SOCKS5" in proxyType:
proxy += ":1080"
proxiesList.append(proxy)
break;
count += 1
cprint("Succesfully added {} proxies!".format(len(proxiesList)), 'green')
def site4(proxiesList):
url = "https://www.proxynova.com/proxy-server-list/country-us/"
user = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"}
r = requests.get(url,headers=user)
data = r.text
soup = BeautifulSoup(data,"html.parser")
proxy = ""
# for ips in soup.find_all("tr",{"class":"spy1xx"}):
for ips in soup.find_all("tr"):
count = 0
for ip in ips.find_all("td",{"align":"left"}):
if count == 0:
proxy = str(ip.get_text(strip=True).replace("document.write('","").replace("'","").replace("+","").replace(");","").replace(" ",""))
if count == 1:
proxy += ":"+str(ip.text).strip()
proxiesList.append(proxy)
break;
count += 1
def loadProxies():
proxiesList = []
cprint("Loading proxies...","green")
site2(proxiesList) # load proxies
# proxiesList = ["13.85.80.251:443"]
# proxiesList = ["13.85.80.251:443"]
# proxiesList = ["144.217.16.78:3128"]
proxiesList = proxiesList[::-1]
proxiesList = proxiesList[:10]
proxiesList = filterConnections(proxiesList) # filter for working connections
# Write to file
with open("proxies.txt", 'w') as outfile:
json.dump(proxiesList, outfile)
cprint("Proxies saved to proxies.txt!","magenta","on_grey", attrs=['bold'])
loadProxies()