wynemo
11/2/2011 - 7:38 AM

parase_reader_share.py

#coding:utf-8
import json
import sys
json_file_name = sys.argv[1]#'C:/Users/zdb/Downloads/shared-items-jas.json',
f1 = open(json_file_name,'r')
o1 = json.load(f1,'utf-8')
i = 1
dir1 = u'd:/'
for item in o1['items']:
    name = u''
    url = u''
    try:
        name = item['object']['displayName']
        url = item['object']['url']
    except Exception,e:
        print e
    content = item['object']['content']
    date = item['published']
    f1 = open(dir1 + unicode(i) + u'.html','wb')
    #print type(content)
    f1.write(name.encode('utf-8'))
    f1.write(ur' <br>')
    if url != u'':
        f1.write(url + ur' <br>')
    f1.write(date + ur' <br>')
    f1.write(content.encode('utf-8'))
    f1.close()
    i += 1