How to Get the Sitemap URL for an HTML Document in Python

Cloudmersive
2 min readJul 7, 2021

--

HTML sitemaps are available to users, enabling them to easily view a sitemap and navigate each page of the URL. If you need to retrieve the sitemap URL for an HTML document, we have a quick solution that will simplify the process; the following API can be used in Python to automatically get the sitemap URL from an HTML document allowing for straightforward and complete navigation.

Let’s start the process by installing the SDK:

pip install cloudmersive-convert-api-client

Next, we can input the file or file URL along with our API key into the below code to call the function:

from __future__ import print_function
import time
import cloudmersive_convert_api_client
from cloudmersive_convert_api_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_convert_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_convert_api_client.EditHtmlApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/inputfile' # file | Optional: Input file to perform the operation on. (optional)
input_file_url = 'input_file_url_example' # str | Optional: URL of a file to operate on as input. (optional)
try:
# Gets the sitemap URL for the HTML document
api_response = api_instance.edit_html_html_get_sitemap(input_file=input_file, input_file_url=input_file_url)
pprint(api_response)
except ApiException as e:
print("Exception when calling EditHtmlApi->edit_html_html_get_sitemap: %s\n" % e)

And we’re done! If you need to obtain your API key, you can do so by registering for a free account on the Cloudmersive website; this will provide 800 calls/month across any of our APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet