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:
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:
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.
mortgage_analysis.py
Example output:
🎉 You’ve created a mortgage rate analysis tool with IBM watsonx.ai and Browserbase!

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: