几行代码就能调用智能接口

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

import requests
import urllib
import urllib2

KEY = 'd92d20bc1d8bb3cff585bf746603b2a9'
url = 'http://www.tuling123.com/openapi/api'
req_info = u'讲个笑话'

query = {'key': KEY, 'info': req_info}
headers = {'Content-type': 'text/html', 'charset': 'utf-8'}

 

# 方法一、用requests模块以get方式获取内容
r = requests.get(url, params=query, headers=headers)
print r.text

 

# 方法二、用urllib和urllib2库获取内容
data = urllib.urlencode(query)
req = urllib2.Request(url, data)
f = urllib2.urlopen(req)
print f.read()