import cfscrape
from bs4 import BeautifulSoup
from datetime import date
def main2():
try:
print("Start 2 step || Site - free-proxy-list.net")
scraper = cfscrape.create_scraper()
r = scraper.get('https://free-proxy-list.net')
soup = BeautifulSoup(r.text, 'lxml')
line = soup.find('table', class_='table table-striped table-bordered').find('tbody').find_all('tr')
for tr in line:
td = tr.find_all('td')
ip = td[0].text
port = td[1].text
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip + ":" + port + "\n"))
except Exception as e:
print(e)
def main3():
try:
print("Start 3 step || Site - free.proxy-sale.com")
scraper = cfscrape.create_scraper()
r = scraper.get('https://free.proxy-sale.com')
soup = BeautifulSoup(r.text, 'lxml')
line = soup.find('div', class_="main__table-wrap").find('table').find('tbody').find_all('tr')
for i in line:
td = i.find_all('td', class_="ip")
for n in td:
a = n.find("a").text.replace("Нажмите ⌘-С чтобы скопировать Скопировать в буфер", " ").strip()
ip = a
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip + "\n"))
except Exception as e:
print(e)
def main4():
try:
print("Start 4 step || Site - proxyscrape.com and openproxylist.xyz")
scraper = cfscrape.create_scraper()
response5 = scraper.get("https://openproxylist.xyz/http.txt")
response6 = scraper.get("https://openproxylist.xyz/socks4.txt")
response7 = scraper.get("https://openproxylist.xyz/socks5.txt")
proxies5 = response5.text.strip()
proxies6 = response6.text.strip()
proxies7 = response7.text.strip()
with open("proxy_scraped.txt", "a") as txt_file:
txt_file.write(proxies5+"\n"+proxies6+"\n"+proxies7+"\n")
except Exception as e:
print(e)
def main5():
try:
print("Start 5 step || Site - hidemy.name")
scraper = cfscrape.create_scraper()
r = scraper.get('https://hidemy.name/ru/proxy-list/')
soup = BeautifulSoup(r.text, 'lxml')
line = soup.find('div', class_="table_block").find('table').find('tbody').find_all('tr')
for a in line:
td = a.find_all('td')
ip = td[0].text
port = td[1].text
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip + ":" + port + "\n"))
except Exception as e:
print(e)
kol_st = 0
def main7():
try:
print("Start 7 step || Site - sslproxies.org")
scraper = cfscrape.create_scraper()
r = scraper.get(f'https://www.sslproxies.org/#list')
soup = BeautifulSoup(r.text, 'lxml')
line = soup.find('table', class_="table table-striped table-bordered").find('tbody').find_all('tr')
for a in line:
td = a.find_all('td')
ip = td[0].text
port = td[1].text
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip + ":" + port + "\n"))
except Exception as e:
print(e)
def main8():
try:
print("Start 8 step || Site - spys.one")
scraper = cfscrape.create_scraper()
r = scraper.get(f'https://spys.one')
soup = BeautifulSoup(r.text, 'lxml')
line = soup.find('table', cellspacing="0", cellpadding="2").find('table', cellspacing="1", cellpadding="1", align="left").find_all('tr', class_="spy1x", onmouseover="this.style.background='#002424'")
line2 = soup.find('table', cellspacing="0", cellpadding="2").find('table', cellspacing="1", cellpadding="1",align="left").find_all('tr', class_="spy1xx",onmouseover="this.style.background='#002424'")
for tr in line:
td = tr.find_all('td')
ip = td[0].text
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip + '\n'))
for tr2 in line2:
td2 = tr2.find_all('td')
ip2 = td2[0].text
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip2 + '\n'))
except Exception as e:
print(e)
def main10():
try:
print("Start 10 step || Site - userel.com")
scraper = cfscrape.create_scraper()
r = scraper.get(f'https://userel.com/')
soup = BeautifulSoup(r.text, 'lxml')
line = soup.find('div', class_="proxy").find('table').find_all('tr')
for tr in line:
td = tr.find_all('td')
ip = td[0].text
with open("proxy_scraped.txt", "a+", encoding="utf-8") as f:
f.write(str(ip) + '\n')
except Exception as e:
print(e)
def main11():
try:
print("Start 11 step || Site - ArchiveProxy")
scraper = cfscrape.create_scraper()
ear, month, day = str(date.today()).split('-')
ear = int(ear)
month = int(month)
day = int(day)
for today in range(day):
try:
scoc = scraper.get(f'https://checkerproxy.net/api/archive/{ear}-{month}-{today}').json()
except:
break
try:
for i in range(40000):
with open('proxy_scraped.txt', 'a+') as file:
file.write(scoc[i]['addr'] + '\n')
except:
pass
except Exception as e:
print(e)
if __name__ == "__main__":
main2()
main3()
main4()
main5()
main7()
main8()
main10()
main11()
print("Duplicates cleaning...")
with open("proxy_scraped.txt") as input_:
result = dict.fromkeys(input_).keys()
with open("proxy_scraped.txt", "w") as output:
print(*result, file=output, sep="")
print("Duplicates successfully cleared!")