Skip to content

Instantly share code, notes, and snippets.

@wong2
Last active December 10, 2015 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wong2/4405430 to your computer and use it in GitHub Desktop.
Save wong2/4405430 to your computer and use it in GitHub Desktop.
小黄鸡
#-*-coding:utf-8-*-
import requests
import cookielib
class SimSimi:
def __init__(self):
self.session = requests.Session()
self.session.get('http://www.simsimi.com/talk.htm')
self.headers = {
'Referer':'http://www.simsimi.com/talk.htm'
}
self.url = 'http://www.simsimi.com/func/req?lc=ch&msg=%s'
def chat(self, message=''):
if message.strip():
r = self.session.get(self.url % message.strip(), headers=self.headers)
try:
return r.json()['response']
except:
return u'呵呵'
else:
return u'叫我干嘛'
if __name__ == '__main__':
simi = SimSimi()
print simi.chat('最后一个问题')
@mdjhny
Copy link

mdjhny commented Jan 3, 2013

哈哈,不错,好玩儿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment