Skip to content

Instantly share code, notes, and snippets.

@wynemo
Created November 2, 2011 07:38
Show Gist options
  • Save wynemo/1333105 to your computer and use it in GitHub Desktop.
Save wynemo/1333105 to your computer and use it in GitHub Desktop.
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment