伟大的python可以无所不能,目前小的工作都交给Python处理了,以下代码演示通过苹果接口获取App数据的方法。
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import urllib2
import demjson
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def writeLine(file,content):
file.write(content)
def getAppInfo(appid):
url = "http://itunes.apple.com/lookup?id=%d&country=cn" % (appid)
req = urllib2.Request(url);
resdata = urllib2.urlopen(req)
res = resdata.read()
json = demjson.decode(res)
file = "%d.txt" % (appid)
f = open(file, "w+")
writeLine(f, ('=====appid=====:\n' + (str)(json['results'][0]['trackId'])) + '\n')
writeLine(f, ('=====trackName==