Newbie to Python & want to use it for tasks automation

I have started learning python and want to use it to automate the tasks. I am optimizing a website which is built in core PHP. I have to create a sitemap manually to add new website pages in the sitemap. I want to automate this task. Can anyone help to automate the task?

Thanks in advance