python get proxy list | Free and Live Proxies Scraping

Scrape Proxies With Python

Yea!!! I have written a code on how to scrape free and live proxies with python.Simply, I scraped all the proxies from website.It has both http and https
Here you go

from bs4 import BeautifulSoup as b
import lxml
import urllib.request as urllib
import time
def grabProxies():
    site = ''
    hdr = {'User-Agent': 'Mozilla/5.0'}
    req = urllib.Request(site,headers=hdr) #sending requests with headers
    url = urllib.urlopen(req).read() #opening and reading the source code
    html = b(url,"lxml")                #structuring the source code in proper format
    rows = html.findAll("tr")       #finding all rows in the table if any.
    proxies = []
    for row in rows:
        cols = row.find_all('td')
        cols = [ele.text for ele in cols]
            ipaddr = cols[0]        #ipAddress which presents in the first element of cols list
            portNum = cols[1]       #portNum which presents in the second element of cols list
            proxy = ipaddr+":"+portNum  #concatinating both ip and port
            portName = cols[6]          #portName variable result will be yes / No
            if portName == "no":
                proxies.append(str(proxy)+" -> http") #if yes then it appends the proxy with https
                proxies.append(str(proxy)+" -> https") #if no then it appends the proxy with http
    for j in proxies:



Leave a Reply

Your email address will not be published. Required fields are marked *