script000kiddies000

proxy.py

Apr 9th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. from bs4 import BeautifulSoup as bs
  2. import requests
  3.  
  4. def get_free_proxies():
  5. url = "https://free-proxy-list.net/"
  6. # get the HTTP response and construct soup object
  7. soup = bs(requests.get(url).content, "html.parser")
  8. proxies = []
  9. for row in soup.find("table", attrs={"id": "proxylisttable"}).find_all("tr")[1:]:
  10. tds = row.find_all("td")
  11. try:
  12. ip = tds[0].text.strip()
  13. port = tds[1].text.strip()
  14. host = f"{ip}:{port}"
  15. proxies.append(host)
  16. except IndexError:
  17. continue
  18. return proxies
  19.  
  20.  
  21. def cek_proxy(proxies):
  22. for i in range(len(proxies)):
  23. session = requests.Session()
  24. proxy = proxies[i]
  25. session.proxies = {"http": proxy, "https": proxy}
  26. print(f'\rmencoba proxy ke : [{i}] {proxies[i]}', end=' ', flush=True)
  27. # print(f'mencoba proxy ke : [{i}] {proxies[i]}',flush=True)
  28. try:
  29. #icanhazip.com
  30. session.get("https://i.nhentai.net", timeout=1.5).text.strip()
  31. except:
  32. continue
  33. break
  34. print(f'\nproxy di temukan: {proxies[i]}')
  35. return session
  36.  
  37. cek_proxy(get_free_proxies())
Advertisement
Add Comment
Please, Sign In to add comment