Skip to content

Instantly share code, notes, and snippets.

@silgon
Last active May 26, 2020 17:49
Show Gist options
  • Save silgon/fb27d237c68e3487f8e01a56a084cee9 to your computer and use it in GitHub Desktop.
Save silgon/fb27d237c68e3487f8e01a56a084cee9 to your computer and use it in GitHub Desktop.
#extracted from: https://www.scrapehero.com/how-to-rotate-proxies-and-ip-addresses-using-python-3/
import requests
from lxml.html import fromstring
def get_proxies():
url = 'https://free-proxy-list.net/'
response = requests.get(url)
parser = fromstring(response.text)
proxies = set()
for i in parser.xpath('//tbody/tr'):
if i.xpath('.//td[7][contains(text(),"yes")]'):
#Grabbing IP and corresponding PORT
proxy = ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0]])
proxies.add(proxy)
return proxies
#extracted from: https://www.scrapehero.com/how-to-rotate-proxies-and-ip-addresses-using-python-3/
import requests
from lxml.html import fromstring
def get_proxies():
url = 'https://free-proxy-list.net/'
response = requests.get(url)
parser = fromstring(response.text)
proxies = set()
for i in parser.xpath('//tbody/tr'):
if i.xpath('.//td[7][contains(text(),"yes")]') and (
i.xpath('.//td[5][contains(text(),"anonymous")]') or
i.xpath('.//td[5][contains(text(),"elite proxy")]') ):
proxy = ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0]])
proxies.add(proxy)
return proxies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment