Setup your Environment
To use Hyperbrowser with your code, you will need an API Key. You can get one easily from the dashboard . Once you have your API Key, add it to your .env
file as HYPERBROWSER_API_KEY
.
Scrape a Site
Next, you can scrape any site by simply setting up the Hyperbrowser client and providing the site's url.
Node Python
Copy import { Hyperbrowser } from "@hyperbrowser/sdk" ;
import { config } from "dotenv" ;
config ();
const client = new Hyperbrowser ({
apiKey : process . env . HYPERBROWSER_API_KEY ,
});
const main = async () => {
const scrapeResult = await client . scrape .startAndWait ({
url : "https://example.com" ,
});
console .log ( "Scrape result:" , scrapeResult);
};
main ();
Copy import os
from dotenv import load_dotenv
from hyperbrowser import AsyncHyperbrowser as Hyperbrowser
from hyperbrowser . models . scrape import StartScrapeJobParams
# Load environment variables from .env file
load_dotenv ()
# Initialize Hyperbrowser client
client = Hyperbrowser (api_key = os. getenv ( "HYPERBROWSER_API_KEY" ))
async def main ():
# Start scraping and wait for completion
scrape_result = await client . scrape . start_and_wait (
StartScrapeJobParams (url = "https://example.com" )
)
print ( "Scrape result:" , scrape_result)
if __name__ == "__main__" :
import asyncio
asyncio . run ( main ())
View Session in Dashboard
You can view all your sessions in the dashboard and see their recordings or other key metrics like logs.