top of page

Get the Sitemap URL for an HTML Document in Node.JS



Need to retrieve the sitemap link URL from your HTML document? We’ve got you covered. In this brief tutorial, we will demonstrate how you can avoid incorrect information utilizing an API in Node.JS to obtain the sitemap URL for an HTML document as needed.


Let’s start by running this command to install the SDK:

npm install cloudmersive-convert-api-client --save

Or, adding this snippet to your package.json:

"dependencies": {
    "cloudmersive-convert-api-client": "^2.6.3"
  }

Now, we’re ready to call the function with the following code:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';

var apiInstance = new CloudmersiveConvertApiClient.EditHtmlApi();

var opts = { 
  'inputFile': Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer), // File | Optional: Input file to perform the operation on.
  'inputFileUrl': "inputFileUrl_example" // String | Optional: URL of a file to operate on as input.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.editHtmlHtmlGetSitemap(opts, callback);

The sitemap URL for the input HTML file will be delivered promptly. To retrieve your API key, visit the Cloudmersive website and register for a free account; this will provide 800 monthly calls across any of our APIs.



Source: Medium - Cloudmersive


The Tech Platform

0 comments
bottom of page