Ghost.py和代理 [英] Ghost.py and proxy

查看:127
本文介绍了Ghost.py和代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释如何使 Ghost.py 与代理一起工作吗?我已经签出了代码,但是它不存在.

Is anyone able to explain how to make Ghost.py work with a proxy? I've checked out the code but it's not there.

推荐答案

我已经在ghost.py文件中找到了它.他们在其中做得很好.这是第835行的set_proxy()方法.我尚未尝试过的只是使用它的方法:

I've found it in the ghost.py file. They did a very good job in it. It's a method on line 835, as set_proxy(). It's just how to use it that I'm yet to try out:

def set_proxy(self, type_, host='localhost', port=8888, user='',
        password=''):
    """Set up proxy for FURTHER connections.

    :param type_: proxy type to use: \
        none/default/socks5/https/http.
    :param host: proxy server ip or host name.
    :param port: proxy port.
    """
    _types = {
        'default': QNetworkProxy.DefaultProxy,
        'none': QNetworkProxy.NoProxy,
        'socks5': QNetworkProxy.Socks5Proxy,
        'https': QNetworkProxy.HttpProxy,
        'http': QNetworkProxy.HttpCachingProxy
    }

    if type_ is None:
        type_ = 'none'
    type_ = type_.lower()
    if type_ in ['none', 'default']:
        self.manager.setProxy(QNetworkProxy(_types[type_]))
        return
    elif type_ in _types:
        proxy = QNetworkProxy(_types[type_], hostName=host, port=port,
            user=user, password=password)
        self.manager.setProxy(proxy)
    else:
        raise ValueError('Unsupported proxy type:' + type_ \
        + '\nsupported types are: none/socks5/http/https/default')

我现在不了解的是"QNetworkProxy.DefaultProxy"的含义.据说这是默认代理.那么,默认代理是什么?

What I don't understand now is what "QNetworkProxy.DefaultProxy" means. It's said to be the default proxy. So, what's the default proxy?

这篇关于Ghost.py和代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆