生成sitemap.xml

This commit is contained in:
zeek 2020-03-22 11:56:38 +08:00
parent cd07ca54a0
commit 71186f3bec
2 changed files with 5 additions and 4 deletions

View File

@ -7,7 +7,7 @@ from bs4 import BeautifulSoup
url_root = 'https://git.zeekling.cn'
url_mine_list = [
'https://git.zeekling.cn',
'https://git.zeekling.cn/',
'https://git.zeekling.cn/zeekling'
]
@ -27,7 +27,8 @@ url_robot_arr = [
url_static_arr = [
'.js',
'.css',
'.cscc'
'.cscc',
'None'
]

View File

@ -9,11 +9,11 @@ import get_url
def create_xml(filename, url_list):
header = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
file = open(filename, 'a', encoding='utf-8')
file = open(filename, 'w', encoding='utf-8')
file.writelines(header)
file.close()
times = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S+00:00")
for url in url_list:
times = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S+00:00")
urls = re.sub(r"&", "&amp;", url)
ment = " <url>\n <loc>%s</loc>\n <lastmod>%s</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>\n" % (urls, times)
file = open(filename, 'a', encoding='utf-8')