Import HTML with Regex in Google Sheets with OS_IMPORTHTML
Introduction
In Google Sheets, you may be on the lookout for a personalized function capable of analyzing HTML content using regular expressions. If that's the case, you're in the right place. Allow me to introduce you to the OS_IMPORTHTML custom function, meticulously developed to assist you in achieving this objective within Google Sheets.
Installation
Install from Google Workspace Marketplace
YouTube
If you're more of a visual learner, watch this video for step-by-step instructions. While you're there, consider subscribing to my channel for future updates and content.
Demo Use Case
In this demonstration, we utilize the custom function OS_IMPORTHTML to retrieve information about the installations of the add-on. This data is obtained from the add-on installation page on the Google Marketplace Store. To test the feature, you can input the following parameters:
Example
OS_IMPORTHTML("https://workspace.google.com/marketplace/app/onescript/929805390763", "<div aria-label="".+this app\."">([^<]+)<\/div>", "i")
About
Import matched text from the HTML with regex. (Due to the limitation of Workspace Add-on, if the URL is not whitelisted you can try my editor addon Chalkline with the same function https://workspace.google.com/u/0/marketplace/app/chalkline/467201976339)
url
The public URL of the HTMl to be imported.
regex
The regular expressions to be used to parse the HTML.
flags
The flags of the regular expressions.
* Due to the grouping of the installation in the regular expression parameter, the function will return two values. This allows you to index the result if desired.
* When utilizing the regex parameter, it's important to pay close attention to how double quotes should be handled, especially if they are present within the parameter itself.
OneScript Custom Functions (Follow for More Updates)
Links
Hire Me on Upwork Donate YouTube Github Twitter / X Instagram Upwork Projects
Comments
Post a Comment