Advertisement
Guest User

Untitled

a guest
Jul 10th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. {
  2. "Contents": [
  3. {
  4. "LastModified": "2018-06-15T20:40:28.000Z",
  5. "ETag": "\"80f71457cb2f2aae8d5183e9b3befda7\"",
  6. "StorageClass": "STANDARD",
  7. "Key": "000097-20030605.pdf",
  8. "Owner": {
  9. "DisplayName": "bpr-admin",
  10. "ID": "6822198f40e279e66289724108f3a791719ef9422f72611ca45b0ad7cd5e9d12"
  11. },
  12. "Size": 15646
  13. },
  14. {
  15. "LastModified": "2018-06-15T20:40:28.000Z",
  16. "ETag": "\"dafa3ed3e751f2de9030e99f80133113\"",
  17. "StorageClass": "STANDARD",
  18. "Key": "000097-20040317.pdf",
  19. "Owner": {
  20. "DisplayName": "bpr-admin",
  21. "ID": "6822198f40e279e66289724108f3a791719ef9422f72611ca45b0ad7cd5e9d12"
  22. },
  23. "Size": 16134
  24. }, ......
  25.  
  26. -----------------------------------------------------------------------
  27. import json
  28. from shutil import copyfileobj
  29. sitemap_f = open('sitemap_test.xml', 'a', encoding = 'utf-8')
  30. index_f = open('index_test.html', 'a')
  31.  
  32. sm_header = open('sitemap-header.txt', 'r')
  33. copyfileobj(sm_header, sitemap_f)
  34. close(sm_header)
  35.  
  36. with open('objects.json') as f:
  37. data = json.load(f)
  38. objects = data['Contents']
  39. for object in objects:
  40. loc = '<loc>' + object['Key'] + '</loc>'
  41. mod = '<lastmod>' + object['LastModified'] + '</lastmod>'
  42. sitemap_f.writelines(['<url>','\t' + loc,'\t' + mod,'\t' + '<changefreq>monthly</changefreq>','\t' + '<priority>0.5</priority>','</url>'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement