Skip to main content
Here are the steps:
  1. Set up your environment
  2. Capture a web page screenshot
  3. Analyze the screenshot with IBM watsonx.ai
  4. Create a mortgage rate report

Build a mortgage rate analysis tool

1. Set up your environment

Install the required dependencies and set up your API keys.
Create a .env file with your API keys:
.env
Make sure to install Playwright dependencies after installation by running playwright install in your terminal.

2. Capture a web page screenshot

Use Browserbase to navigate to the Freddie Mac mortgage rates page and capture a screenshot of the rate information that’s embedded in an iframe:
Python screenshot.py

3. Analyze the screenshot with IBM watsonx.ai

Now, use IBM watsonx.ai’s vision model to analyze the captured screenshot and extract the mortgage rate information:
Python analyze.py

4. Create a mortgage rate report

Combine the screenshot capture and analysis steps into a complete solution that produces a nicely formatted report.
Python mortgage_analysis.py
Example output:
🎉 You’ve created a mortgage rate analysis tool with IBM watsonx.ai and Browserbase!

Expected output

The screenshot step writes freddie_mac_rates.jpeg. The combined script prints Mortgage Rate Analysis: followed by the model response. Review the image alongside the response before using any extracted rate values.

Cleanup

The screenshot function closes the browser on success. If it fails earlier, release the session using Manage browser sessions. Delete the generated freddie_mac_rates.jpeg file and any local report copies when you no longer need them.

Next steps

With this foundation, you can build more advanced workflows:
  • Schedule regular rate checks and track trends over time
  • Compare rates across multiple mortgage providers
  • Create dashboards to monitor rate changes and predict future trends
  • Fill out mortgage applications using extracted data

Best practices

  • Handle dynamic content: Some websites load data asynchronously, so make sure content is fully loaded by adding wait times before capturing screenshots.
  • Add error handling: Implement robust error handling for network issues and page structure changes.
  • Secure your credentials: Never expose API keys in client-side code or public repositories.
For more information, explore: