How to Append an HTML Tag to the HEAD of an HTML Doc in Python

If you are frequently constructing or manipulating HTML documents, it can get tiresome to append HTML tags to each one. In this quick tutorial, we will demonstrate how you can instantly append an HTML tag to the HEAD of an HTML document in Python.

The first step in the process is to run this command to install the API client:

pip install cloudmersive-convert-api-client

After the installation, we can call the function with the following code:

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))
html_tag = 'html_tag_example' # str | The HTML tag to append.
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:
# Append an HTML tag to the HEAD section of an HTML Document
api_response = api_instance.edit_html_html_append_header_tag(html_tag, 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_append_header_tag: %s\n" % e)

Your results will be delivered at the end of the operation — easy!

--

--

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

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