Example #1
0
# -*- coding: utf-8 -*-
# @Time    : 2018/1/27 上午3:53
# @Author  : wudizhangzhi

import requests

try:
    requests.packages.urllib3.disable_warnings()
except ImportError:
    pass
from user_agent import generate_user_agent

from hupu.utils import getSortParam, get_android_id, get_random_Imei
from hupu.api import logger

log = logger.getLogger(__name__)

HUPU_API_VERSION = '7.1.15'

MODE_LIST = ['live', 'news']


class SignSession(requests.Session):  # 继承
    def request(self,
                method,
                url,
                params=None,
                data=None,
                headers=None,
                cookies=None,
                files=None,
Example #2
0
# @Time    : 2018/1/27 下午2:22
# @Author  : wudizhangzhi
from __future__ import absolute_import
from __future__ import print_function

import time
import traceback

import colored
import requests

from hupu.api import logger
from hupu.utils import colored_text, parse_message, SYSTEM, PREFERREDENCODING
from hupu.messages.entries import to_text

log = logger.getLogger(__name__)
log = logger.getLogger('websocket')
import websocket


class HupuLiveWebSocket(object):
    def __init__(self, client, game, host=None, port=None, livetype=None):
        """
        虎扑文字直播websocket的基类
        :param client: client id
        :param host: 
        :param port: 
        :param livetype: 文字直播的类型: [NBA, CBA]
        """
        self.client = client
        self.game = game