Back to all resources
jQuery
CMS
Web Scraping
DOM Manipulation

Load All CMS Items

By Jared Malan
This JavaScript code is used to parse and display CMS (Content Management System) items from a specific webpage. The code consists of three main functions: parseCMSItems, getCMSItems, and renderList. 

The parseCMSItems function takes a DOM (Document Object Model) as an argument and finds all the CMS items within the DOM using the jQuery find method. It then pushes each CMS item into the cmsArray. If there is a URL for the next page of CMS items, it calls the getCMSItems function with the new URL. If there is no next page, it calls the renderList function to display the CMS items.

The getCMSItems function takes a URL as an argument and uses the jQuery get method to retrieve the HTML of the webpage at the given URL. It then calls the parseCMSItems function with the retrieved HTML.

The renderList function logs the cmsArray to the console and then uses the jQuery html method to add the CMS items in the cmsArray to a div with the class "companies