美文网首页
Python获取iOS应用数据

Python获取iOS应用数据

作者: 风轻知道 | 来源:发表于2016-09-07 15:28 被阅读95次

伟大的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=====:\n' + json['results'][0]['trackName']) + '\n')

    writeLine(f, ('=====description=====:\n' + json['results'][0]['description'] + '\n'))

    writeLine(f, ('=====link=====:\n' + json['results'][0]['trackViewUrl'] + '\n'))

    writeLine(f, ('=====bundleId=====:\n' + (str)(json['results'][0]['bundleId']) + '\n'))

    writeLine(f, ('=====releaseAt=====:\n' + json['results'][0]['currentVersionReleaseDate'] + '\n'))

    writeLine(f, ('=====releaseNotes=====:\n' + json['results'][0]['releaseNotes'] + '\n'))

    writeLine(f, ('=====icon=====:\n' + json['results'][0]['artworkUrl100'] + '\n'))

    writeLine(f, ('=====fileSizeBytes=====:\n' + (str)(json['results'][0]['fileSizeBytes']) + '\n'))

    f.close()

getAppInfo(1102002763);

相关文章

网友评论

      本文标题:Python获取iOS应用数据

      本文链接:https://www.haomeiwen.com/subject/sxbjettx.html