ebook_get_request.py 1.1 KB
Newer Older
ToTensor's avatar
ToTensor 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
import json
import requests
import logging


logger = logging.getLogger(__name__)


def get_chapter_content(params):
    url = 'http://192.168.50.117:9003/v1/chapter/content'

    headers = {
        "Cookie":"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
    }

    result = requests.get(url=url, params=params, headers=headers)

    if result.status_code == 200:
        ret = json.loads(result.text)
        logger.info('request success')
        content = ret['data']
        return content
    else:
        logger.info('request failed!!!!!')
        return {}


def get_chapter_list(params):
    url = 'http://192.168.50.117:9003/inner/v1/chapter/list'

    headers = {
        "Cookie":"UserToken=149ba8a7a8d341bbbe41f904c4c9b176;UserName=xiuxiuyayayy"
    }

    result = requests.get(url=url, params=params, headers=headers)

    if result.status_code == 200:
        ret = json.loads(result.text)
        logger.info('request success')
        content = ret['data']
        return content
    else:
        logger.info('request failed!!!!!')
        return {}