Skip to content

Instantly share code, notes, and snippets.

@sousatg
Created January 3, 2016 02:49
Show Gist options
  • Save sousatg/23aa5916836605a6d13c to your computer and use it in GitHub Desktop.
Save sousatg/23aa5916836605a6d13c to your computer and use it in GitHub Desktop.
API developed with Flask to retrive a list of proxy address and their connections.
from flask import Flask, jsonify
from lxml import etree
from urllib3 import PoolManager
import time
app = Flask(__name__)
def parseProxyString(proxyString):
keys = ["address", "port"]
values = proxyString.split(':')
proxyDict = dict(zip(keys,values))
return proxyDict
def recScrape(cx):
if cx < 0 : return []
url = 'http://proxy-list.org/english/index.php?p=' + str( cx )
r = PoolManager().urlopen( 'GET', url )
if r.status != 200: return []
root = etree.HTML(r.data)
entryElems = root.xpath('//*[@id="proxy-table"]//li[@class="proxy"]')
return entryElems + recScrape(cx-1)
def scrapProxyAddress():
elemEntries = recScrape(1)
entries = [entry.text for entry in elemEntries if entry.text != 'Proxy']
entries = map(parseProxyString, entries)
return entries
@app.route('/')
def index():
values = scrapProxyAddress()
proxyDict = { "result" : values, "date" : int(time.time()) }
return jsonify( proxyDict )
@app.route('/websites')
def websites():
return jsonify( {"result":[
"omeuip.com",
"piratebay.org",
"thepiratebay.org",
"thepiratebay.se",
"yts.to",
"toppt.tv",
"uber.com",
"tudodownloadpt-pt2.blogspot.pt",
"amofilmes.net",
"avxhome.se",
"bitsnoop.com",
"dramatize.com",
"ilovefilmesonline.com",
"megafilmeshd.tv",
"megafilmesonline.net",
"projectfreetv.so",
"rapidmoviez.com",
"sanet.me",
"sceper.ws",
"series-cravings.me",
"topdezfilmes.org",
"toptorent.org",
"watch-series-tv.to",
"armagedomfilmes.biz",
"baixartorrent.net",
"clubedodownload.info",
"cucirco.eu",
"ddlvalley.rocks",
"filmesdetv.com",
"megafilmesonlinehd.com",
"onlinemovies-pro.com",
"rlslog.net",
"seedpeer.eu",
"supercineonline.com",
"telona.org",
"torlock.com",
"torrentfunk.com",
"torrents.net",
"tubeplus.is",
"tuga-filmes.com",
"yourbittorrent.com",
"mp3skull.online",
"gigatuga.io",
"megapirata.net"
]} )
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment