Exemple #1
0
def push_url(domain):
    while True:
        global success_count
        global failure_count
        referer = PushTool.get_url(domain)
        r = PushTool.get_url(domain)
        # proxy = PushTool.get_proxy()
        # proxy = b'115.219.74.242:26043'
        # if isinstance(proxy, bytes):
        #     proxy = proxy.decode('utf8')
        # proxies = {"http": "http://{proxy}".format(proxy=proxy)}
        headers = {
            'User-Agent': PushTool.user_agent(),
            'Referer': referer,
            'Accept': '*/*',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language':
            'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Connection': 'keep-alive',
            'Host': 'api.share.baidu.com',
        }

        conn = requests.Session()
        conn.headers = headers
        # print(headers)
        # 将cookiesJar赋值给会话
        cookiesJar = requests.utils.cookiejar_from_dict(cookie,
                                                        cookiejar=None,
                                                        overwrite=True)
        conn.cookies = cookiesJar
        payload = {'r': r, 'l': referer}
        code = 404
        url = ''
        try:
            # res = conn.get('http://api.share.baidu.com/s.gif', params=payload, timeout=10, proxies=proxies)
            res = conn.get(
                'https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif?',
                params=payload,
                timeout=20)
            # res = conn.get('https://github.com')
            code = res.status_code
            if code == 200:
                success_count += 1
            else:
                failure_count += 1
            url = res.url
        except:
            traceback.print_exc()
            failure_count += 1
        print('----------------------')
        print(code, url)
        print('success:%d  failure:%d' % (success_count, failure_count))
Exemple #2
0
def push_url_one(domain):
    while True:
        global success_count
        global failure_count
        referer = PushTool.get_url(domain)
        r = PushTool.get_url(domain)
        headers = {
            'User-Agent': PushTool.user_agent(),
            'Referer': referer,
            'Accept': '*/*',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language':
            'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Connection': 'keep-alive',
            'Host': 'api.share.baidu.com',
        }

        conn = requests.Session()
        conn.headers = headers
        # print(headers)
        # 将cookiesJar赋值给会话
        cookiesJar = requests.utils.cookiejar_from_dict(cookie,
                                                        cookiejar=None,
                                                        overwrite=True)
        conn.cookies = cookiesJar
        payload = {'r': r, 'l': referer}
        code = 404
        url = ''
        try:
            # res = conn.get('http://api.share.baidu.com/s.gif', params=payload, timeout=10, proxies=proxies)
            res = conn.get('http://api.share.baidu.com/s.gif',
                           params=payload,
                           timeout=1)
            code = res.status_code
            if code == 200:
                success_count += 1
            else:
                failure_count += 1
            url = parse.unquote(res.url)
        except:
            # traceback.print_exc()
            failure_count += 1
        print('----------------------')
        print(code, url)
        print('success:%d  failure:%d' % (success_count, failure_count))
Exemple #3
0
async def register_user(session, cookie_jar):
    global success_num
    global fail_num
    global start_time
    referer = PushTool.get_url('http://www.61k.com/lsj')
    r = PushTool.get_url('http://www.61k.com/lsj')
    headers = {
        'User-Agent': PushTool.user_agent(),
        'Referer': referer,
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language':
        'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
        'Connection': 'keep-alive',
        'Host': 'api.share.baidu.com',
    }
    status = 233
    try:
        payload = {
            'r': r,
            'l': referer,
        }
        async with ClientSession(cookies=cookie_jar) as session:
            async with session.post(url='http://api.share.baidu.com/s.gif',
                                    data=payload,
                                    headers=headers,
                                    timeout=2) as response:
                r = await response.read()
                if r == b'' and response.status == 200:
                    success_num += 1
                else:
                    fail_num += 1
                status = response.status
    except Exception as e:
        fail_num += 1
    this_time = datetime.now()
    spend = this_time - start_time
    speed_sec = int(success_num / spend.seconds)
    speed_day = (speed_sec * 60 * 60 * 24) / 10000000
    percent = success_num / (fail_num + success_num) * 100
    print("%s 成功%s 预计(day/千万):%s M 成功率:%.2f%% 状态码:%s" %
          (datetime.now(), success_num, speed_day, percent, status))
Exemple #4
0
def https_push(domain):
    global success_code
    global fail_code
    url = ''
    while True:
        try:
            r = PushTool.get_url(domain)
            i = PushTool.get_url(domain)
            headers = {
                'User-Agent': PushTool.user_agent(),
                'Referer': r,
                'Accept': '*/*',
                'Connection': 'keep-alive',
                'Host': 'sp0.baidu.com',
            }
            conn = requests.Session()
            conn.headers = headers
            # print(headers)
            # 将cookiesJar赋值给会话
            cookiesJar = requests.utils.cookiejar_from_dict(cookie,
                                                            cookiejar=None,
                                                            overwrite=True)
            conn.cookies = cookiesJar
            target = '%s?r=%s&l=%s' % (server, r, i)
            # http = requests.get(target, headers=headers)
            http = conn.get(target)
            url = parse.unquote(http.url)
            if http.content == b'' and http.status_code == 200:
                success_code += 1
                print('成功 %s 失败 %s %s' % (success_code, fail_code, url))
            else:
                fail_code += 1
                print('成功 %s 失败 %s %s' % (success_code, fail_code, url))
        except:
            fail_code += 1
            print('成功 %s 失败 %s %s' % (success_code, fail_code, url))