Exemplo n.º 1
0
def charge_proxy(ips):
    settings = user_settings.get()
    if 'proxy' in settings:
        ip_url = settings['proxy']
    else:
        logger.logger('请先设置代理IP')
        message_box(
            '没有设置代理IP请先设置 设置之后请验证 确保返回的只有一个代理IP 例如 123.234.345.12:9808',
            '代理设置', 'error')
        return '127.0.0.1:1080'
        try:
            r_text = requests.get(ip_url).text
            if '白名单' in r_text:
                message_box('即将使用真实IP' + r_text, '获取代理IP出错', 'error')
                time.sleep(1)
                return '127.0.0.1:1080'
        except:
            message_box('请设置正确的代理IP 设置后请验证保证可返回一个代理IP 如果真实IP可用将使用真实IP进行采集',
                        '代理设置', 'error')
            return '127.0.0.1:1080'
        else:
            while '请求' in r_text:
                time.sleep(1)
                r_text = requests.get(ip_url).text

            ip_ports = r_text.split('\r\n')[:-1]
            if len(ip_ports) == 1:
                return ip_ports[0]
            return ip_ports
Exemplo n.º 2
0
def charge_proxy():
    # 读取代理IP URL
    settings = user_settings.get()
    print(settings)
    if 'proxy' in settings:
        ip_url = settings['proxy']
    else:
        logger.logger('请先设置代理IP')
        message_box(
            '没有设置代理IP请先设置 设置之后请验证 确保返回的只有一个代理IP 例如 123.234.345.12:9808',
            '代理设置', 'error')
        return '127.0.0.1:1080'
    try:
        r_text = requests.get(ip_url).text
        if "白名单" in r_text:
            message_box('即将使用真实IP' + r_text, '获取代理IP出错', 'error')
            time.sleep(1)
            return '127.0.0.1:1080'
    except:
        message_box('请设置正确的代理IP 设置后请验证保证可返回一个代理IP 如果真实IP可用将使用真实IP进行采集', '代理设置',
                    'error')
        return '127.0.0.1:1080'
    while "请求" in r_text:
        time.sleep(1)
        print('等待返回代理IP...')
        r_text = requests.get(ip_url).text
    return r_text
Exemplo n.º 3
0
def use_proxy_directly():
    """
    :return: 是否直接使用代理
    """
    from instance import user_settings
    settings = user_settings.get()
    if 'use_proxy' in settings:
        if settings['use_proxy'] == 'true':
            return False
        return True
    else:
        return False
Exemplo n.º 4
0
 def get(self):
     return user_settings.get()