Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup as bs
- import requests
- def get_free_proxies():
- url = "https://free-proxy-list.net/"
- # get the HTTP response and construct soup object
- soup = bs(requests.get(url).content, "html.parser")
- proxies = []
- for row in soup.find("table", attrs={"id": "proxylisttable"}).find_all("tr")[1:]:
- tds = row.find_all("td")
- try:
- ip = tds[0].text.strip()
- port = tds[1].text.strip()
- host = f"{ip}:{port}"
- proxies.append(host)
- except IndexError:
- continue
- return proxies
- def cek_proxy(proxies):
- for i in range(len(proxies)):
- session = requests.Session()
- proxy = proxies[i]
- session.proxies = {"http": proxy, "https": proxy}
- print(f'\rmencoba proxy ke : [{i}] {proxies[i]}', end=' ', flush=True)
- # print(f'mencoba proxy ke : [{i}] {proxies[i]}',flush=True)
- try:
- #icanhazip.com
- session.get("https://i.nhentai.net", timeout=1.5).text.strip()
- except:
- continue
- break
- print(f'\nproxy di temukan: {proxies[i]}')
- return session
- cek_proxy(get_free_proxies())
Advertisement
Add Comment
Please, Sign In to add comment