Last active
August 29, 2015 14:01
-
-
Save wendal/3df5030d66d663f946ed to your computer and use it in GitHub Desktop.
快速打印南航的特价票
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
''' | |
Created on 2014-5-28 | |
快速打印南航的特价票 | |
@author: wendal | |
''' | |
import json | |
import urllib2 | |
import operator | |
def load(inter=False): | |
url = "http://eunion.csair.com/E-UNION/data/avprice/getMinPrice.json?inter=" | |
if inter : | |
url += "Y" | |
else : | |
url += "N" | |
data = str(urllib2.urlopen(url, None, 5).read())[1:-1] | |
return json.loads(data)["FROMOFLIGHTS"] | |
if __name__ == '__main__': | |
for item in load(1) : # 1 国际, 0 国内 | |
print "-----------------------------------------------------------" | |
print item["DEPCTIYNAME_ZH"], ":" | |
m = {} | |
for fly in item["FLIGHT"] : | |
m[fly["ARRCTIYNAME_ZH"]] = fly["MINPRICE"] | |
m = sorted(m.iteritems(), key=operator.itemgetter(1)) | |
for v in m : | |
print "\t", v[0], v[1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
要西