Ask AI
Skip to main content

Get HTML of webpage

Function: Get HTML of webpage

This function allows your application to visit any public webpage, retrieve its entire HTML content, and store it for further use within your application. It's perfect for gathering information from websites without needing to manually copy and paste.

Input

  • Webpage URL: A piece of text. Specify the complete web address (URL) of the page you want to fetch the HTML from. Make sure it starts with http:// or https:// (e.g., https://www.example.com). This input is required.
  • Query parameters: A list of key/value pairs combined in an object. Optionally, you can add specific parameters to the URL. These are often used to filter content or provide specific instructions to the website (e.g., \{"category": "news", "page": "2"\}).

Output

  • Response: A piece of text. This is the name of the variable where the retrieved HTML content of the webpage will be stored. By default, this variable will be named HTML.
  • Status: A text indicating the status of an execution. This is the name of the variable that will hold the outcome of the attempt to fetch the webpage. Possible values include:
    • SUCCESS: The HTML was fetched successfully.
    • BAD_REQUEST: The provided URL was invalid or malformed.
    • UNAUTHORIZED: The request was denied due to authentication issues (less common for public pages).
    • NOTFOUND: The webpage at the specified URL could not be found (e.g., a 404 error). By default, this variable will be named STATUS.

Execution Flow

Real-Life Examples

Example 1: Fetching the HTML of a Company's Homepage

Imagine you want to regularly check the content of your company's homepage for updates or specific keywords.

  • Inputs:
    • Webpage URL: https://www.yourcompany.com
    • Query parameters: (Leave empty)
  • Result: The application visits https://www.yourcompany.com, retrieves its full HTML content, and stores it in a variable named HTML. The STATUS variable will be set to SUCCESS.

Example 2: Retrieving Product Listings from an E-commerce Site with Filters

You might want to get the HTML of a specific category of products from an online store, filtered by price or availability.

  • Inputs:
    • Webpage URL: https://www.onlinestore.com/products
    • Query parameters: \{"category": "electronics", "sort_by": "price_asc"\}
  • Result: The application constructs the URL https://www.onlinestore.com/products?category=electronics&sort_by=price_asc, fetches the HTML content of the filtered product page, and saves it to the HTML variable. The STATUS variable will be SUCCESS.

Example 3: Handling an Incorrect Webpage Address

If a user accidentally provides a malformed or incomplete URL, the function will gracefully handle the error.

  • Inputs:
    • Webpage URL: my-website
    • Query parameters: (Leave empty)
  • Result: The application identifies that my-website is not a valid URL format. It will not attempt to fetch any content, and the STATUS variable will be set to BAD_REQUEST. The HTML variable will remain empty.