當前位置: 首頁>>代碼示例>>Python>>正文


Python proxy.Proxy方法代碼示例

本文整理匯總了Python中proxy.Proxy方法的典型用法代碼示例。如果您正苦於以下問題:Python proxy.Proxy方法的具體用法?Python proxy.Proxy怎麽用?Python proxy.Proxy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在proxy的用法示例。


在下文中一共展示了proxy.Proxy方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: insert

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def insert():
    sql = SqlManager()
    name = request.args.get('name')
    proxy = Proxy()
    proxy.set_value(
        ip=request.args.get('ip'),
        port=request.args.get('port'),
        country=request.args.get('country', None),
        anonymity=request.args.get('anonymity', None),
        https=request.args.get('https', 'no'),
        speed=request.args.get('speed', -1),
        source=request.args.get('source', name),
    )

    result = sql.insert_proxy(name, proxy)
    data = {
        'result': result
    }

    return json.dumps(data, indent=4) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:22,代碼來源:dataserver.py

示例2: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        pattern = re.compile(
		'<tr><td>(.*?)</td><td>(.*?)</td><td>(.*?)</td><td.+?>(.*?)</td><td>(.*?)</td><td.+?>(.*?)</td><td.+?>(.*?)</td><td.+?>(.*?)</td></tr>',
                re.S)
        items = re.findall(pattern, response.body.decode())

        if items is not None:
            for item in items:
                proxy = Proxy()
                proxy.set_value(
                        ip = item[0],
                        port = item[1],
                        country = item[3],
                        anonymity = item[4],
                        source = self.name,
                )

                self.add_proxy(proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:20,代碼來源:usproxy.py

示例3: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        pattern = re.compile(
                '<tr>\s.*?<td.*?>(.*?)</td>\s.*?<td.*?>(.*?)</td>\s.*?<td.*?>(.*?)</td>\s.*?<td.*?>('
                '.*?)</td>\s.*?<td.*?>(.*?)</td>\s.*?<td.*?>(.*?)</td>\s.*?<td.*?>(.*?)</td>\s.*?</tr>',
                re.S)
        items = re.findall(pattern, response.body.decode())

        for item in items:
            proxy = Proxy()
            proxy.set_value(
                    ip = item[0],
                    port = item[1],
                    country = item[4],
                    anonymity = item[2],
                    source = self.name,
            )

            self.add_proxy(proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:20,代碼來源:kuaidaili.py

示例4: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        pattern = re.compile('gp.insertPrx\((.*?)\)', re.S)
        items = re.findall(pattern, response.body.decode())
        for item in items:
            data = json.loads(item)
            #端口用的是十六進製
            port = data.get('PROXY_PORT')
            port = str(int(port, 16))

            proxy = Proxy()
            proxy.set_value(
                    ip = data.get('PROXY_IP'),
                    port = port,
                    country = data.get('PROXY_COUNTRY'),
                    anonymity = data.get('PROXY_TYPE'),
                    source = self.name,
            )

            self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:21,代碼來源:gatherproxy.py

示例5: __init__

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def __init__(self, *a, **kw):
        super(ProxylistplusSpider, self).__init__(*a, **kw)

        self.urls = ['https://list.proxylistplus.com/Fresh-HTTP-Proxy-List-%s' % n for n in range(1, 3)]
        self.headers = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Encoding': 'gzip, deflate, br',
            'Accept-Language': 'en-US,en;q=0.5',
            'Cache-Control': 'max-age=0',
            'Connection': 'keep-alive',
            'Host': 'list.proxylistplus.com',
            'If-Modified-Since': 'Mon, 20 Feb 2017 07:47:35 GMT',
            'If-None-Match': 'list381487576865',
            'Referer': 'https://list.proxylistplus.com/Fresh-HTTP-Proxy',
            'Upgrade-Insecure-Requests': '1',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:51.0) Gecko/20100101 Firefox/51.0',
        }

        self.is_record_web_page = False
        self.init() 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:22,代碼來源:proxylistplus.py

示例6: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        self.write(response.body)

        sel = Selector(response)
        infos = sel.xpath('//tbody/tr').extract()
        for i, info in enumerate(infos):
            if i == 0:
                continue

            val = Selector(text = info)
            ip = val.xpath('//td[1]/text()').extract_first()
            port = val.xpath('//td[2]/text()').extract_first()
            country = val.xpath('//td[3]/div/text()').extract_first()
            anonymity = val.xpath('//td[6]/text()').extract_first()

            proxy = Proxy()
            proxy.set_value(
                    ip = ip,
                    port = port,
                    country = country,
                    anonymity = anonymity,
                    source = self.name,
            )

            self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:27,代碼來源:hidemy.py

示例7: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        sel = Selector(text = response.body)
        infos = sel.xpath('//tr[@class="odd"]').extract()
        for info in infos:
            val = Selector(text = info)
            ip = val.xpath('//td[2]/text()').extract_first()
            port = val.xpath('//td[3]/text()').extract_first()
            country = val.xpath('//td[4]/a/text()').extract_first()
            anonymity = val.xpath('//td[5]/text()').extract_first()

            proxy = Proxy()
            proxy.set_value(
                    ip = ip,
                    port = port,
                    country = country,
                    anonymity = anonymity,
                    source = self.name,
            )

            self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:22,代碼來源:xicidaili.py

示例8: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        pattern = re.compile('<tr><td>(.*?)</td><td>(.*?)</td><td>(.*?)</td><td>(.*?)</td><td>(.*?)</td></tr>',
                             re.S)
        items = re.findall(pattern, response.body.decode())
        for i, item in enumerate(items):
            if i >= 1:
                proxy = Proxy()
                proxy.set_value(
                        ip = item[0],
                        port = item[1],
                        country = item[2],
                        anonymity = item[3],
                        source = self.name
                )

                self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:18,代碼來源:sixsixip.py

示例9: get_proxy_with_id

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def get_proxy_with_id(self, table_name, id):
        data = self.db[table_name].find_one({'_id': id})
        logging.debug(data)
        proxy = Proxy()
        proxy.set_value(
            ip=data.get('ip'),
            port=data.get('port'),
            country=data.get('country'),
            anonymity=data.get('country'),
            https=data.get('https'),
            speed=data.get('speed'),
            source=data.get('source'),
            vali_count=data.get('vali_count')
        )
        proxy.id = data.get('_id')
        return proxy 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:18,代碼來源:mongodb.py

示例10: get_usage_text

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def get_usage_text():
    authors_text = read_file_lines('AUTHORS')

    lines = []
    lines.append("#"*40)
    lines.append("# SWParser v{} - Summoners War Proxy # ".format(VERSION))
    lines.append("#"*40)
    lines.append("\tWritten by:\n\t\tKaKaRoTo\n")
    lines.append("\tAuthors:")
    for author in authors_text:
        lines.append("\t\t{}".format(author))

    lines.append("\n\tPlugins:")
    for plugin in SWPlugin.plugins:
        lines.append("\t\t{}".format(plugin.name))

    lines.append("\nLicensed under LGPLv3 and available at: \n\t{}\n".format(GITHUB))
    return "\n".join(lines) 
開發者ID:kakaroto,項目名稱:SWProxy,代碼行數:20,代碼來源:SWProxy.py

示例11: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        super(ProxyDBSpider, self).parse_page(response)
        for table_item in response.xpath('//tbody/tr'):
            ip,port = self.parse_ip(table_item.xpath('.//td[1]/script/text()').extract_first())
            country = table_item.xpath('.//td/img/@title').extract_first().strip()
            anonymity = table_item.xpath('.//td/span/text()').extract_first().strip()
            proxy = Proxy()
            proxy.set_value(
                    ip = ip,
                    port = port,
                    country = country,
                    anonymity = anonymity,
                    source = self.name
            )
            self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:17,代碼來源:proxydb.py

示例12: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        pattern = re.compile('<tr class=(.*?)</tr>', re.S)
        items = re.findall(pattern = pattern, string = response.body)
        for i, item in enumerate(items):
            if i > 0:
                if 'async' in item:
                    continue

                ip_pattern = re.compile('IPDecode\(\"(.*?)\"\)', re.S)
                ip_decode = re.findall(ip_pattern, item)[0]
                ip_url = urllib.unquote(ip_decode)
                ip_soup = BeautifulSoup(ip_url, 'lxml')
                ip = ip_soup.text.encode()

                item = '<tr class=' + item + '</tr>'
                soup = BeautifulSoup(item, 'lxml')
                tbodys = soup.find_all('td')

                proxy = Proxy()
                proxy.set_value(
                        ip = ip,
                        port = tbodys[1].text.encode(),
                        country = tbodys[4].text.encode(),
                        anonymity = tbodys[3].text.encode(),
                        source = self.name,
                )

                self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:30,代碼來源:freeproxylists.py

示例13: parse_page

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def parse_page(self, response):
        self.write(response.body)

        sel = Selector(response)
        infos = sel.xpath('//tbody/tr').extract()
        for i, info in enumerate(infos):
            if i == 0:
                continue

            val = Selector(text = info)
            ip = val.xpath('//td[1]/text()').extract_first()
            port = val.xpath('//td[2]/text()').extract_first()
            country = val.xpath('//td[6]/text()').extract_first()
            anonymity = val.xpath('//td[3]/text()').extract_first()
            https = val.xpath('//td[4]/text()').extract_first()

            proxy = Proxy()
            proxy.set_value(
                    ip = ip,
                    port = port,
                    country = country,
                    anonymity = anonymity,
                    source = self.name,
            )

            self.add_proxy(proxy = proxy) 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:28,代碼來源:ip181.py

示例14: get_proxy_with_id

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def get_proxy_with_id(self, table_name, id):
        proxy = Proxy()
        try:
            command = "SELECT * FROM {0} WHERE id=\'{1}\'".format(table_name, id)
            result = self.query_one(command)
            if result != None:
                # data = {
                #     'id': result[0],
                #     'ip': result[1],
                #     'port': result[2],
                #     'country': result[3],
                #     'anonymity': result[4],
                #     'https': result[5],
                #     'speed': result[6],
                #     'source': result[7],
                #     'save_time': result[8],
                #     'vali_count': result[9],
                # }
                proxy = Proxy()
                proxy.set_value(
                    ip=result[1],
                    port=result[2],
                    country=result[3],
                    anonymity=result[4],
                    https=result[5],
                    speed=result[6],
                    source=result[7],
                    vali_count=result[9])
                proxy.id = result[0]
                proxy.save_time = result[8]
        except Exception as e:
            logging.exception('mysql get_proxy_ids exception msg:%s' % e)

        return proxy 
開發者ID:awolfly9,項目名稱:IPProxyTool,代碼行數:36,代碼來源:mysql.py

示例15: test_load_real_or_cached_object

# 需要導入模塊: import proxy [as 別名]
# 或者: from proxy import Proxy [as 別名]
def test_load_real_or_cached_object(self):
        p1 = Proxy(Implementation("RealObject1"))

        # the first time we call do_stuff we need to load the real object
        with captured_output() as (out, err):
            p1.do_stuff()
        output = out.getvalue().strip()
        self.assertEqual(output, "load RealObject1\ndo stuff on RealObject1")

        # after that, loading is unnecessary (we use the cached object)
        with captured_output() as (out, err):
            p1.do_stuff()
        output = out.getvalue().strip()
        self.assertEqual(output, "do stuff on RealObject1") 
開發者ID:jackdbd,項目名稱:design-patterns,代碼行數:16,代碼來源:test_design_patterns.py


注:本文中的proxy.Proxy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。