import requests
from Entity.Variables import prologueList

BaseUrl = "https://crawlclient.api.yolozs.com/api/common/"
# BaseUrl = "http://192.168.1.174:8101/api/common/"


class Requester():
    comment = "comment"
    prologue = "prologue"

    @classmethod
    def requestPrologue(cls, token):
        headers = {
            "vvtoken": token,
        }
        url = BaseUrl + cls.prologue
        result = requests.get(headers=headers, url=url)
        json = result.json()
        print("json",json
              )
        data = json.get("data")
        print("返回的数据",data)
        for i in data:
            prologueList.append("hello")


    # 翻译
    @classmethod
    def translation(cla, msg, country="英国"):
        parame = {
            "msg":msg,
            "country":country,
        }
        url = "http://ai.zhukeping.com/translation"
        result = requests.request(url=url, json=parame, method="POST")
        json = result.json()
        data = json.get("data")
        print(data)
        return data

    # ai聊天
    @classmethod
    def chatToAi(cls, param):
        url = "http://ai.zhukeping.com/chat"
        result = requests.request(url=url, json=param, method="POST")
        json = result.json()
        data = json.get("data", {})
        return data