Extracted directly from the human web code. Https://github.com/insun/xiaohuangji is too lazy to apply for SIMSIMI_KEY, if forged User-Agent and Referer can also get the json string #! /Usr/bin/env python #-*-coding: UTF-8-*-# read data from simsimi import requestsimport cookielibimport socketimport randomimport syssys. path. append ('.. ') reload (sys) sys. setdefaultencoding ('utf-8') try: from settings import simsimi_key1_t: SIMSIMI_KEY = ''class SimSimi: def _ init _ (self): self. session = requests. session () self. chat_url = 'HTTP: // www.simsimi.com/func/req? Lc = ch & msg = % s 'self. api_url = 'HTTP: // api.simsimi.com/request.p? Key = % s & lc = ch & ft = 1.0 & text = % s 'if not SIMSIMI_KEY: self. initSimSimiCookie () def initSimSimiCookie (self): self. session. headers. update ({'user-agent': 'mozilla/5.0 (X11; Ubuntu; Linux i686; rv: 18.0) Gecko/20100101 Firefox/100'}) self. session. get ('HTTP: // www.simsimi.com/talk.htm') self. session. headers. update ({'Referer': 'http: // www.simsimi.com/talk.htm'}) self. session. get ('HTTP: // www.simsimi.com/talk.ht M? Lc = ch ') self. session. headers. update ({'Referer': 'http: // www.simsimi.com/talk.htm? Lc = Ch'}) def getSimSimiResult (self, message, method = 'normal'): if method = 'normal': r = self. session. get (self. chat_url % message) else: url = self. api_url % (SIMSIMI_KEY, message) r = requests. get (url) return r def chat (self, message = ''): if message: r = self. getSimSimiResult (message, 'normal' if not SIMSIMI_KEY else 'api ') try: answer = r. json () ['response'] return answer. encode ('utf-8') encode t: Return random. choice (['Ha ','... ',' = ',' =. = ']) Else: return' What Do I Do? 'simsimi = simsimi () def handle (data, bot): return SimSimi. chat (data ['message']) if _ name _ = '_ main _': print handle ({'message': 'Last question '}, none) print handle ({'message': 'Another question '}, None) print handle ({'message':' actually I have three problems '}, None) refer: python simulates simsimi chat room to call simsimi api: http://lidongbest5.com/blog/12/ github xiaohuangji: https://github.com/hupili/xiaohuangji