Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "Contents": [
- {
- "LastModified": "2018-06-15T20:40:28.000Z",
- "ETag": "\"80f71457cb2f2aae8d5183e9b3befda7\"",
- "StorageClass": "STANDARD",
- "Key": "000097-20030605.pdf",
- "Owner": {
- "DisplayName": "bpr-admin",
- "ID": "6822198f40e279e66289724108f3a791719ef9422f72611ca45b0ad7cd5e9d12"
- },
- "Size": 15646
- },
- {
- "LastModified": "2018-06-15T20:40:28.000Z",
- "ETag": "\"dafa3ed3e751f2de9030e99f80133113\"",
- "StorageClass": "STANDARD",
- "Key": "000097-20040317.pdf",
- "Owner": {
- "DisplayName": "bpr-admin",
- "ID": "6822198f40e279e66289724108f3a791719ef9422f72611ca45b0ad7cd5e9d12"
- },
- "Size": 16134
- }, ......
- -----------------------------------------------------------------------
- import json
- from shutil import copyfileobj
- sitemap_f = open('sitemap_test.xml', 'a', encoding = 'utf-8')
- index_f = open('index_test.html', 'a')
- sm_header = open('sitemap-header.txt', 'r')
- copyfileobj(sm_header, sitemap_f)
- close(sm_header)
- with open('objects.json') as f:
- data = json.load(f)
- objects = data['Contents']
- for object in objects:
- loc = '<loc>' + object['Key'] + '</loc>'
- mod = '<lastmod>' + object['LastModified'] + '</lastmod>'
- 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