import datetime
def generate_xml_entry(author_name, index):
now = datetime.datetime.utcnow().isoformat() + '+00:00'
xml_entry = f'''<url>
<loc>https://www.example.cn/search/{author_name.strip()}/1</loc>
<lastmod>{now}</lastmod>
</url>
'''
return xml_entry
def main(input_file, output_file):
with open(input_file, 'r', encoding='utf-8') as infile:
lines = infile.readlines()
with open(output_file, 'w', encoding='utf-8') as outfile:
for index, line in enumerate(lines, start=1):
xml_entry = generate_xml_entry(line, index)
outfile.write(xml_entry)
if __name__ == "__main__":
input_txt = "inout.txt"
output_txt = "output.txt"
main(input_txt, output_txt)