Skip to content

Instantly share code, notes, and snippets.

@maplebeats
Created February 6, 2013 05:17
Show Gist options
  • Save maplebeats/4720521 to your computer and use it in GitHub Desktop.
Save maplebeats/4720521 to your computer and use it in GitHub Desktop.
def simi_init(self):
simi_Jar = cookiejar.CookieJar()
self.simi_opener = request.build_opener(request.HTTPCookieProcessor(simi_Jar))
self._headers = {
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1",
"Accept-Language":"zh-cn,en;q=0.8,en-us;q=0.5,zh-hk;q=0.3",
"Accept-Encoding":"deflate",
"Referer":"http://www.simsimi.com/talk.htm"
}
url = "http://www.simsimi.com/func/req?%s" % parse.urlencode({"msg": "hi", "lc": "zh"})
self._request(url=url, opener=self.simi_opener)
def simi_bot(self, req):
url = "http://www.simsimi.com/func/req?%s" % parse.urlencode({"msg": req, "lc": "zh"})
res = self._request(url, opener=self.simi_opener)
if res == "{}":
return False
else:
return json.loads(res)['response']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment