Skip to main content
Connect ZenRows’ web scraping capabilities to your MuleSoft workflows through the Anypoint platform. This integration enables automated data extraction from websites directly within your existing automation processes.

What Is MuleSoft?

MuleSoft is a no-code/low-code automation platform that connects and exchanges data between various applications and systems. One of its core components is the MuleSoft Anypoint platform, which enables users to integrate systems via an API-focused approach.

Use Cases

Here are some use cases of MuleSoft-ZenRows integration.
  • Competitor monitoring: Schedule automated scraping of competitor websites to track pricing, product changes, or content updates.
  • Sentiment analysis: Gather product reviews data from various sources with ZenRows and analyze their sentiment using LLM integration.
  • Demand forecasting: Use cron jobs to scrape demand signals from retail and ecommerce sites with ZenRows. Calculate trends and historical moves with JavaScript via Anypoint’s Scripting module. Store time-series data in a database and forecast anticipated demand using LLM.
  • Best deal recommendation: Collect product data from various platforms with ZenRows and use an LLM to analyze key points, such as price, demand history, reviews, and ratings, to recommend the best deal for your customers.

Initial Integration Steps via Anypoint Platform

The best way to integrate MuleSoft with ZenRows is via Anypoint. This guide assumes that you already have an Anypoint account with the Anypoint Studio downloaded and installed. We’ll create a scraping workflow that extracts data from an Amazon product page and stores it in a JSON file.

Step 1: Create and deploy a ZenRows API Spec

  1. Log in to MuleSoft via the Anypoint platform.
  2. Click the icon at the top left and go to Design Center. anypoint-menu.png
  3. Click Create + at the top-left and select New API Specification. anypoint-design-center-create
  4. Give your project a name (e.g., ZenRows Universal Scraper). Then click Create API. anypoint-project-setup
  5. The Design Center creates a new zenrows-universal-scraper.raml file. Remove the existing content in the RAML code box and paste the following ZenRows RAML configuration inside the code box. This configuration defines the required specs and parameters to use the ZenRows Universal Scraper API:
    RAML
  6. Click Get. Then, click Publish at the top right. anypoint-api-spec-creation
  7. Keep the Asset Version and API Version as 1.0.0 and v1, respectively. Under LifeCycle State, select Stable.
  8. Click Publish to Exchange.
  9. Close the confirmation modal. anypoint-exchange-deployment-confirmation
  10. Click the menu icon at the top left and go to Exchange to view your published API spec in the Anypoint Exchange marketplace. anypoint-exchange-zenrows-scraper-displayed

Step 2: Import the ZenRows API Spec into Anypoint Studio

  1. Launch the Anypoint Studio on your machine.
  2. Click File at the top left and go to New. Then, select Mule Project. anypoint-studio-file-menu-options
  3. Give your project a name (e.g., Scraper) and click Finish. anypoint-studio-mule-project
  4. Double-click the <project.xml> (scraperflow.xml) file on the left sidebar to load the flow canvas.
  5. From the Mule Palette on the right side of the canvas, click Search in Exchange. anypoint-exchange-option
  6. Click Add Account and authenticate Anypoint Studio with your Anypoint account if you haven’t done so already.
  7. Search for ZenRows in the search bar and select the ZenRows Universal Scraper API spec from the result table.
  8. Click Add to load the API spec into the Anypoint Studio Mule Palette.
  9. Click Finish. anypoint-studio-api-spec-connection
  10. To test the import, search for ZenRows via the Mule Palette search bar. The ZenRows Universal Scraper spec now appears in the Mule Palette. anypoint-studio-mule-pallet-api-spec

Step 3: Create the scraping workflow in Anypoint Studio

  1. From the Mule Palette, search for Scheduler and drag it into the canvas. Rename your scheduler as you desire.
  2. From the Scheduling Strategy dropdown, choose between Frequency or Cron. We’ve chosen Frequency in this case and scheduled the flow to run the request within 10 seconds using a 10-second delay. schedule-flow-settings
  3. Search for Logger and drag it into the Process tab inside the Scraperflow. We’ll use this to log the beginning of automation.
  4. In the Message box, type a trigger alert message (e.g., Schedule triggered!). anypoint-studio-logger-flow
  5. Search for ZenRows in the Mule Palette. Then, drag the ZenRows Universal Scraper API spec into the workflow.
  6. Click the Connector Configuration dropdown and select Create a new configuration.
  7. Rename the ZenRows flow as you desire (e.g., Product Scraper Flow).
  8. Click the + icon next to Connector Configuration and click okay to set it as ZenRows. anypoint-studio-connector-settings
  9. Set the necessary parameters. We’ve used the following in this guide:
    • ZenRows API key.
    • Target URL
    • Js_render = true
    • Premium_proxy = true
    • Proxy_country = us
    • css_extractor:
      JSON
  10. Press Ctrl+S on your keyboard to save the current flow. anypoint-studio-zenrows-scraper-api-spec-params
  11. Again, search and drag a Logger flow into the workflow to output the scraping result.
  12. Rename the new logger (e.g., Data Logger)
  13. In the Logger’s Message, click fx and type #[payload. anypoint-data-logger

Step 4: Save the data

  1. Search for File Write in the Mule Palette and drag it into your workflow.
  2. Rename the Writer (e.g., JSON Writer).
  3. Paste the destination folder path in the Path field (e.g., D:/Anypoint-result/result.json). Keep the Content field as payload and the Write Mode as OVERWRITE.
  4. Press Ctrl+S to save the changes. anypoint-studio-final-flow

Step 5: Run the flow

To run the flow, right-click scraperflow.xml, click Run As > Mule Application. anypoint-mule-application-execution-options Check your JSON storage directory and open the created JSON file to see the scraped data. Here’s a sample JSON result:
result.json
Congratulations! 🎉You just integrated ZenRows into your MuleSoft Anypoint automation workflow.

Troubleshooting

Error 429 (Too Many Requests)

  • Solution: Increase the Scheduler’s frequency and delay to space out the requests and prevent multiple requests from running within a short time frame.

Build failed during Anypoint Studio compilation

  • Solution 1: Check for errors in each flow and fix them individually.
  • Solution 2: Ensure you enter the correct ZenRows parameters. The js_render and premium_proxy parameters should be set to true to increase the success rate.
  • Solution 3: Verify that your API key is entered correctly.

Incomplete or empty data

  • Solution 1: Ensure that you enter the correct CSS selectors.
  • Solution 2: Validate that the CSS extractor array is formatted correctly.
  • Solution 3: If using autoparse, ensure that ZenRows supports the target page. Check the ZenRows Data Collector Marketplace to view the supported websites.

File write access denied:

  • Solution 1: If storing data locally, give the current Anypoint Studio workplace access to the storage location.
  • Solution 2: Ensure that you append the file name to the file path specified in the Anypoint Studio Writer flow. For example, D:/Anypoint-result is wrong. The correct file path format should be D:/Anypoint-result/result.json.

Frequently Asked Questions (FAQ)

ZenRows doesn’t charge you extra for making scraping requests via Anypoint. However, while Anypoint comes with a 30-day free trial, it requires an upfront financial commitment, which limits your ability to use the scraping workflow.
Yes, you can save data locally to a CSV file using Anypoint’s File Write module. MuleSoft’s Anypoint also supports remote database connection using the JDBC (Java Database Connectivity) driver.
No, but integrating ZenRows with MuleSoft is straightforward. You only need to paste the RAML file containing the required ZenRows Universal Scraper API specifications into the Anypoint Platform and publish it to the Exchange. You can then interact with ZenRows visually in your workflow via the published API specification.
Although Anypoint doesn’t have built-in support for LLM tools, you can load your desired model using Anypoint’s HTTP request flow. This involves authorizing the LLM via the Bearer Authorization header and returning its response using a Logger flow or directly writing it into a file.