Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 28th, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #coding:utf-8
  2. import json
  3. import sys
  4. json_file_name = sys.argv[1]#'C:/Users/zdb/Downloads/shared-items-jas.json',
  5. f1 = open(json_file_name,'r')
  6. o1 = json.load(f1,'utf-8')
  7. i = 1
  8. dir1 = u'd:/'
  9. for item in o1['items']:
  10.     name = u''
  11.     url = u''
  12.     try:
  13.         name = item['object']['displayName']
  14.         url = item['object']['url']
  15.     except Exception,e:
  16.         print e
  17.     content = item['object']['content']
  18.     date = item['published']
  19.     f1 = open(dir1 + unicode(i) + u'.html','wb')
  20.     #print type(content)
  21.     f1.write(name.encode('utf-8'))
  22.     f1.write(ur' <br>')
  23.     if url != u'':
  24.         f1.write(url + ur' <br>')
  25.     f1.write(date + ur' <br>')
  26.     f1.write(content.encode('utf-8'))
  27.     f1.close()
  28.     i += 1