-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parsik.py
221 lines (192 loc) · 7.94 KB
/
Parsik.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
214
215
216
217
218
219
220
221
import re
import requests
import sqlite3
from bs4 import BeautifulSoup as bsoup
from PyQt6 import QtCore, QtGui, QtWidgets
import pingspeed
# import tablebd
from database import Database
class Paarser:
def __init__(self, url):
self.user_ip_list = []
self.user_country_list = []
self.user_speed_list = []
self.user_port_list = []
self.user_type_list = []
if url == 'https://free.proxy-sale.com/':
self.screb1(url)
if url == 'http://foxtools.ru/Proxy':
self.screb2(url)
if url == 'https://best-proxies.ru/proxylist/free/':
self.screb3(url)
if url == 'https://www.freeproxy.world/':
self.screb4(url)
if url == 'https://www.proxy-list.download/HTTP':
self.screb5(url)
pass
def clear(self):
self.user_ip_list = []
self.user_country_list = []
self.user_speed_list = []
self.user_port_list = []
self.user_type_list = []
def screb1(self, url1):
#self.db.bd(user_ip_list, user_port_list, user_type_list, user_country_list, user_speed_list)
page = requests.get(url1)
result = bsoup(page.text, 'lxml')
for el0 in result.find_all('td', class_='ip'):
for el1 in el0.find_all('a'):
user_IP = ((el1.text).split("\t")[0])
self.user_ip_list.append(user_IP)
for el00 in result.find_all('td', class_='country'):
user_country = (el00.text.split()[0])
self.user_country_list.append(user_country)
for el00 in result.find_all('td'):
for el0 in result.find_all('div', class_='progress-bar blue stripes'):
for el1 in el0.find_all('i'):
user_speed = (el1.text).split(" мс")[0]
if user_speed != "":
self.user_speed_list.append(user_speed)
for el0 in result.find_all('div', class_='kc-elm kc-css-517022 kc-raw-code'):
el0 = re.sub(r'\s+', ' ', str(el0))
_start = [i for i in range(len(el0)) if el0.startswith('attrPorts = attrPorts + "," + ', i)]
_end = [i for i in range(len(el0)) if el0.startswith('</script>', i)]
for i in range(len(_start)):
self.user_port_list.append(int(el0[_start[i] + 30:_end[i] - 2]))
for el0 in result.find_all('td'):
for el1 in el0.find_all('a'):
temp = ((el1.text).split('\t')[0])
temp1 = (temp.split('\n')[0])
user_type = ((re.sub('[^A-Z]', '', temp1)))
self.user_type_list.append(user_type)
user_type_list = [i for i in self.user_type_list if i]
#db = Database().bd()
Database().bd(self.user_ip_list, self.user_port_list, user_type_list, self.user_country_list, self.user_speed_list)
self.clear()
def screb2(self,url2):
iter = []
page = requests.get(url2)
result = bsoup(page.text, 'lxml')
for ell1 in result.find_all('td'):
temp = ((ell1.text))
iter.append(temp)
for i in range(1, len(iter), 8):
self.user_ip_list.append(iter[i])
for i in range(2, len(iter), 8):
self.user_port_list.append(iter[i])
for i in range(3, len(iter), 8):
self.user_country_list.append(iter[i])
for i in range(5, len(iter), 8):
tempp=((re.sub('[^A-Z]', '',iter[i])))
self.user_type_list.append(str(tempp))
for i in range(6, len(iter), 8):
self.user_speed_list.append(iter[i])
Database().bd(self.user_ip_list, self.user_port_list, self.user_type_list, self.user_country_list,
self.user_speed_list)
self.clear()
def screb3(self, url3):
iter = []
port = []
ip = []
country = []
speed = []
type = []
page = requests.get(url3)
result = bsoup(page.text, 'lxml')
for ell1 in result.find_all('td'):
temp = ((ell1.text))
iter.append(temp)
# print(iter)
for i in range(1, len(iter), 8):
port.append(iter[i])
port = [line.strip() for line in port]
self.user_port_list.extend(port[:10])
for i in range(0, len(iter), 8):
ip.append(iter[i])
ip = [line.strip() for line in ip]
self.user_ip_list.extend(ip[:10])
for i in range(2, len(iter), 8):
country.append(iter[i])
country = [line.strip() for line in country]
self.user_country_list.extend(country[:10])
for i in range(4, len(iter), 8):
speed.append(iter[i])
speed = [line.strip() for line in speed]
self.user_speed_list.extend(speed[:10])
for i in range(5, len(iter), 8):
type.append(iter[i])
type = [line.strip() for line in type]
self.user_type_list.extend(type[:10])
Database().bd(self.user_ip_list, self.user_port_list, self.user_type_list, self.user_country_list,
self.user_speed_list)
self.clear()
def screb4(self, url4):
iter = []
port = []
ip = []
country = []
speed = []
type = []
page = requests.get(url4)
result = bsoup(page.text, 'lxml')
for el2 in result.find_all('tr'):
for el3 in el2.find_all('td'):
tabl = (el3.text.strip())
iter.append(tabl)
for i in range(1, len(iter), 8):
port.append(iter[i])
port = [line.strip() for line in port]
self.user_port_list.extend(port[:10])
for i in range(0, len(iter), 8):
ip.append(iter[i])
ip = [line.strip() for line in ip]
self.user_ip_list.extend(ip[:10])
for i in range(2, len(iter), 8):
country.append(iter[i])
country = [line.strip() for line in country]
self.user_country_list.extend(country[:10])
for i in range(4, len(iter), 8):
speed.append(iter[i])
speed = [line.strip() for line in speed]
self.user_speed_list.extend(speed[:10])
for i in range(5, len(iter), 8):
type.append(iter[i])
type = [line.strip() for line in type]
self.user_type_list.extend(type[:10])
Database().bd(self.user_ip_list, self.user_port_list, self.user_type_list, self.user_country_list,
self.user_speed_list)
self.clear()
def screb5(self,url5):
iter = []
port = []
ip = []
country = []
speed = []
type = []
page = requests.get(url5)
result = bsoup(page.text, 'lxml')
for el2 in result.find_all('td'):
tabl = (el2.text.strip())
iter.append(tabl)
for i in range(1, len(iter), 5):
port.append(iter[i])
port = [line.strip() for line in port]
self.user_port_list.extend(port[:10])
for i in range(0, len(iter), 5):
ip.append(iter[i])
ip = [line.strip() for line in ip]
self.user_ip_list.extend(ip[:10])
for i in range(0, 10):
type.append('HTTP')
self.user_type_list.extend(type)
for i in range(3, len(iter), 5):
country.append(iter[i])
country = [line.strip() for line in country]
self.user_country_list.extend(country[:10])
for i in range(4, len(iter), 5):
speed.append(iter[i])
speed = [line.strip() for line in speed]
self.user_speed_list.extend(speed[:10])
Database().bd(self.user_ip_list, self.user_port_list, self.user_type_list, self.user_country_list,
self.user_speed_list)
self.clear()