Python 3 Script to Build a Sitemap Generator and Download Sitemap XML File for any Website or Domain Using sitemap-generator Library Full Tutorial For Beginners

Python 3 Script to Build a Sitemap Generator and Download Sitemap XML File for any Website or Domain Using sitemap-generator Library Full Tutorial For Beginners

 

Welcome folks today in this post we will be building a python sitemap generator using sitemap-generator library in python. All the full source code of the application is given below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the following library inside your python project by using the pip command

 

pip install sitemap-generator

 

After installing this library make an app.py file and copy paste the following code to it

 

import sys
import logging
from pysitemap import crawler

if __name__ == '__main__':
    if '--iocp' in sys.argv:
        from asyncio import events, windows_events
        sys.argv.remove('--iocp')
        logging.info('using iocp')
        el = windows_events.ProactorEventLoop()
        events.set_event_loop(el)

    # root_url = sys.argv[1]
    root_url = 'https://freemediatools.com'
    crawler(root_url, out_file='sitemap.xml')

 

 

Now here in the above block of python code you need to replace the domain url for which you need to generate the sitemap xml file and then after replacing it just run the python script by executing the below command

See also  Python Script to Print Map of India Using ASCII Characters on Command Line Full Project For Beginners

 

python app.py

 

 

 

 

 

 

Leave a Reply