当前位置: 首页>>代码示例>>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;未经允许,请勿转载。