forked from 41alderson/ProxyPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProxyPy.py
213 lines (168 loc) · 6.39 KB
/
ProxyPy.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import requests
from bs4 import BeautifulSoup
from time import sleep
import os
user_agent = ["Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion"]
url_list_https = "https://api.proxyscrape.com?request=getproxies&proxytype=http&timeout=10000&country=all&ssl=all&anonymity=all"
url_list_socks4 = "https://api.proxyscrape.com?request=getproxies&proxytype=socks4&timeout=10000&country=all"
url_list_socks5 = "https://api.proxyscrape.com?request=getproxies&proxytype=socks5&timeout=10000&country=all"
class scrape_proxy:
@staticmethod
def http():
sleep(2)
print('\n\nStarting Scraping Http/Https Proxies....')
os.system('type NUL > ProxyPy_http.txt') #linux users use os.system('touch ProxyPy_http.txt')
r = requests.get(url_list_https)
with open('ProxyPy_http.txt', 'wb+') as f:
f.write(r.content)
f.close()
sleep(2)
url2 = 'https://www.proxy-list.download/api/v1/get?type=https'
url1 = 'https://www.proxy-list.download/api/v1/get?type=http'
url3 = 'https://cyber-hub.net/proxy/http.txt'
l = requests.get(url2)
ll = requests.get(url1)
lll = requests.get(url3)
with open('ProxyPy_http.txt', 'ab+') as w:
w.write(l.content)
w.write(ll.content)
w.write(lll.content)
w.close()
urll = 'https://www.proxy-daily.com/'
r = requests.get(urll).text
soup = BeautifulSoup(r, features='html.parser')
k = soup.find('div', {'class': 'centeredProxyList freeProxyStyle'})
rep = str(k).replace('<div class="centeredProxyList freeProxyStyle">', '')
rep = rep.replace('</div>', '')
with open('ProxyPy_http.txt', 'a') as ww:
ww.writelines(rep)
ww.close()
print('Leeching Done Successfully')
sleep(2)
print('Removing Duplicates...')
sleep(1)
with open('ProxyPy_http.txt', 'r') as f:
print('Total Http/Https Proxies Available: ', len(f.readlines()))
@staticmethod
def socks4():
sleep(2)
print('\n\nStarting Scraping Socks4 Proxies...')
os.system('type NUL > ProxyPy_socks4.txt') #linux users use os.system('touch ProxyPy_socks4.txt')
r = requests.get(url_list_socks4)
with open('ProxyPy_socks4.txt', 'wb+') as f:
f.write(r.content)
f.close()
url = 'https://www.proxy-list.download/api/v1/get?type=socks4'
rr = requests.get(url)
with open('ProxyPy_socks4.txt', 'ab+') as ff:
ff.write(rr.content)
ff.close()
sleep(2)
urll = 'https://www.proxy-daily.com/'
r = requests.get(urll).text
soup = BeautifulSoup(r, features='html.parser')
k = soup.find('div', {'class': 'centeredProxyList freeProxyStyle'})
rep = str(k).replace('<div class="centeredProxyList freeProxyStyle">', '')
rep = rep.replace('</div>', '')
with open('ProxyPy_socks4.txt', 'a') as ww:
ww.writelines(rep)
ww.close()
print('Removing Duplicates Please Wait')
sleep(2)
with open('ProxyPy_socks4.txt', 'r') as f:
print('Total Socks4 Proxies Available: ', len(f.readlines()))
@staticmethod
def socks5():
sleep(2)
print('\n\nStarting Scraping Socks5 Proxies')
os.system('type NUL > ProxyPy_socks5.txt') #linux users use os.system('touch ProxyPy_socks5.txt')
r = requests.get(url_list_socks5)
with open('ProxyPy_socks5.txt', 'wb+') as f:
f.write(r.content)
f.close()
url = 'https://www.proxy-list.download/api/v1/get?type=socks5'
rr = requests.get(url)
with open('ProxyPy_socks5.txt', 'ab+') as ff:
ff.write(rr.content)
ff.close()
sleep(2)
print('Removing Duplicates Please Wait')
sleep(2)
with open('ProxyPy_socks5.txt', 'r') as f:
print('Total Socks5 Proxies Available: ', len(f.readlines()))
@staticmethod
def get_all():
scrape_proxy.http()
scrape_proxy.socks4()
scrape_proxy.socks5()
def main():
print('''
\n\t\tMENU
1.Get Http/Https Proxies.
2.Get Socks4 Proxies.
3.Get Socks5 Proxies.
4.Get All Proxies At Once.
[All Are Saved In Different Files]
5.Exit.
''')
opt = input('Enter Your Choice: ')
if opt == '1':
scrape_proxy.http()
sleep(1)
input('\nPress Enter To Continue...')
sleep(1)
print('\nReturning To Main Menu..')
sleep(1)
return main()
elif opt == '2':
scrape_proxy.socks4()
sleep(1)
input('\nPress Enter To Continue...')
sleep(1)
print('\nReturning To Main Menu..')
sleep(1)
return main()
elif opt == '3':
scrape_proxy.socks5()
sleep(1)
input('\nPress Enter To Continue...')
sleep(1)
print('\nReturning To Main Menu..')
sleep(1)
return main()
elif opt == '4':
scrape_proxy.get_all()
sleep(1)
input('\nPress Enter To Continue...')
sleep(1)
print('\nReturning To Main Menu..')
sleep(1)
return main()
elif opt == '5':
print('\nSorry To See You Go...\n')
print('Hope You Will Return To Me Again.')
sleep(2)
exit(0)
else:
print('Unknown Option...\nPlease Retry....')
sleep(1.5)
return main()
if __name__ == '__main__':
print('''
______ ______
| ___ \ | ___ \
| |_/ /_ __ ___ __ __ _ _ | |_/ /_ _
| __/| '__|/ _ \\ \/ /| | | || __/| | | |
| | | | | (_) |> < | |_| || | | |_| |
\_| |_| \___//_/\_\ \__, |\_| \__, |
__/ | __/ |
|___/ |___/
A ProxyScraper By 41alderson
''')
sleep(1.5)
print('''
\t\tAuthor: 41_alderson
\t\tGithub: https://github.com/41alderson/TorrentyPy
\t\tTelegram: @destroyer41 ''')
sleep(1.5)
main()