Skip to content

Instantly share code, notes, and snippets.

@pantuts
Created April 18, 2018 02:04
Show Gist options
  • Save pantuts/36212835168057b2d0c64fd3025e9abd to your computer and use it in GitHub Desktop.
Save pantuts/36212835168057b2d0c64fd3025e9abd to your computer and use it in GitHub Desktop.
import re, requests
from bs4 import BeautifulSoup
u = 'https://free-proxy-list.net/'
soup = BeautifulSoup(requests.get(u).text, 'lxml')
trs = soup.find_all('tr')
for tr in trs:
_ip = tr.find('td', text=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
if not _ip: continue
ip = _ip.get_text().strip()
port = _ip.find_next('td').get_text().strip()
country = _ip.find_next().find_next().get_text().strip()
print('{:<20}{:<10}{}'.format(ip, port, country))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment