<filename>GitCraw/proxy.py<gh_stars>0
import requests


from lxml.html import fromstring


class Proxy:
    """
    Get proxy list from https://free-proxy-list.net/
    """

    def get_proxies(self):
        url = 'https://free-proxy-list.net/'
        response = requests.get(url)
        parser = fromstring(response.text)
        proxies = set()
        for i in parser.xpath('//tbody/tr')[:10]:
            if i.xpath('.//td[7][contains(text(),"yes")]'):
                proxy = ":".join([i.xpath('.//td[1]/text()')
                                  [0], i.xpath('.//td[2]/text()')[0]])
                proxies.add(proxy)
        if len(proxies) == 0:
            print("There was an error setting the proxis because there wasn't a usable one. Here are some static proxys "
                  "to use.")
            return ['172.16.58.3:80', '192.168.127.12:45169', '172.16.58.3:8080',
                    '192.168.127.12:3128', '172.16.17.32:8080', '192.168.127.12:3128',
                    '172.16.31.10:8080']
        else:
            return proxies

<filename>GitCraw/proxy.py<gh_stars>0
import requests


from lxml.html import fromstring


class Proxy:
    """
    Get proxy list from https://free-proxy-list.net/
    """

    def get_proxies(self):
        url = 'https://free-proxy-list.net/'
        response = requests.get(url)
        parser = fromstring(response.text)
        proxies = set()
        for i in parser.xpath('//tbody/tr')[:10]:
            if i.xpath('.//td[7][contains(text(),"yes")]'):
                proxy = ":".join([i.xpath('.//td[1]/text()')
                                  [0], i.xpath('.//td[2]/text()')[0]])
                proxies.add(proxy)
        if len(proxies) == 0:
            print("There was an error setting the proxis because there wasn't a usable one. Here are some static proxys "
                  "to use.")
            return ['172.16.58.3:80', '192.168.127.12:45169', '172.16.58.3:8080',
                    '192.168.127.12:3128', '172.16.17.32:8080', '192.168.127.12:3128',
                    '172.16.31.10:8080']
        else:
            return proxies

Get proxy list from https://free-proxy-list.net/