simple_site_crawler/utils.py
def generate_sitemap_xml(urls, filename='sitemap.xml'):
    """
    Generate 'sitemap.xml' file based on passed urls

    :param urls: list of URLs
    :type urls: list of str
    :param filename: output file name
    :type filename: str
    """
    urlset = ET.Element(
        'urlset',
        xmlns='http://www.sitemaps.org/schemas/sitemap/0.9',
    )

    for webpage_url in urls:
        url = ET.SubElement(urlset, 'url')
        ET.SubElement(url, 'loc').text = webpage_url

    pretty_xml = minidom.parseString(
        ET.tostring(urlset),
    ).toprettyxml(
        encoding='UTF-8',
    )

    with open(filename, 'wb') as f:
        f.write(pretty_xml)

    Generate 'sitemap.xml' file based on passed urls

    :param urls: list of URLs
    :type urls: list of str
    :param filename: output file name
    :type filename: str
    
Generate 'sitemap.xml' file based on passed urls
Generate ' sitemap . xml ' file based on passed urls
def generate_sitemap_xml(urls, filename='sitemap.xml'):
    urlset = ET.Element(
        'urlset',
        xmlns='http://www.sitemaps.org/schemas/sitemap/0.9',
    )
    for webpage_url in urls:
        url = ET.SubElement(urlset, 'url')
        ET.SubElement(url, 'loc').text = webpage_url
    pretty_xml = minidom.parseString(
        ET.tostring(urlset),
    ).toprettyxml(
        encoding='UTF-8',
    )
    with open(filename, 'wb') as f:
        f.write(pretty_xml)
def generate_sitemap_xml ( urls , filename = 'sitemap.xml' ) : urlset = ET . Element ( 'urlset' , xmlns = 'http://www.sitemaps.org/schemas/sitemap/0.9' , ) for webpage_url in urls : url = ET . SubElement ( urlset , 'url' ) ET . SubElement ( url , 'loc' ) . text = webpage_url pretty_xml = minidom . parseString ( ET . tostring ( urlset ) , ) . toprettyxml ( encoding = 'UTF-8' , ) with open ( filename , 'wb' ) as f : f . write ( pretty_xml )
Generate 'sitemap.xml' file based on passed urls
Generate ' sitemap . xml ' file based on passed urls
"""
    Generate 'sitemap.xml' file based on passed urls

    :param urls: list of URLs
    :type urls: list of str
    :param filename: output file name
    :type filename: str
    """
urls
list of URLs
list of URLs
filename
output file name
output file name