This is the JavaScript implementation of the Bright Data web scraping workshop. Learn how to choose the right scraping solution based on your needs, optimize for cost efficiency, and maximize success rates.
- Node.js 18 or higher
- Google Chrome browser installed (for browser-based scripts)
- Bright Data account with active zones:
- Datacenter Proxy Zone
- Residential Proxy Zone (optional)
- Web Unlocker Zone
- Scraping Browser Zone
- SERP API Zone
npm installCopy the example environment file and add your credentials:
cp .env.example .envEdit .env with your Bright Data credentials from the Dashboard:
BRIGHTDATA_CUSTOMER_ID=hl_xxxxxxxx
DATACENTER_ZONE=datacenter_proxy
DATACENTER_PASSWORD=your_datacenter_password
RESIDENTIAL_ZONE=residential_proxy
RESIDENTIAL_PASSWORD=your_residential_password
WEB_UNLOCKER_ZONE=unlocker
WEB_UNLOCKER_PASSWORD=your_unlocker_password
SCRAPING_BROWSER_ZONE=scraping_browser
SCRAPING_BROWSER_PASSWORD=your_scraping_browser_password
SERP_API_TOKEN=your_serp_api_token
SERP_API_ZONE=serp1. Simple HTTP Request (simple_request.js)
What it demonstrates:
- Basic HTTP requests through proxies using
axios - Impact of headers and cookies on success rate
- Baseline for cost-efficient scraping
- Compare Datacenter vs Residential IPs
Run it:
npm run simpleConfiguration: Edit the script to toggle:
USE_RESIDENTIAL- Switch between Datacenter and Residential proxiesUSE_HEADERS- Enable/disable browser-like headersUSE_COOKIES- Enable/disable cookiesNUM_REQUESTS- Number of parallel requests
Default Configuration:
USE_RESIDENTIAL:false(uses Datacenter proxy)USE_HEADERS:false(disabled - try enabling to see improved success rates!)USE_COOKIES:falseNUM_REQUESTS:10
2. Browser with Proxy (browser_with_proxy.js)
What it demonstrates:
- Using Puppeteer with Chrome and proxies
- Browser automatically handles JavaScript rendering
- Headers/cookies in browser context
- Request blocking for efficiency
Run it:
npm run browserConfiguration:
USE_RESIDENTIAL- Switch proxy typesUSE_REAL_BROWSER- Use installed Chrome vs ChromiumUSE_HEADERS- Custom HTTP headersUSE_COOKIES- Session cookiesBLOCK_REQUESTS- Block images/CSS/fonts
Default Configuration:
USE_RESIDENTIAL:falseUSE_REAL_BROWSER:true(uses your installed Chrome)USE_HEADERS:true(enabled by default)USE_COOKIES:falseBLOCK_REQUESTS:false
3. Web Unlocker Demo (unlocker_demo.js)
What it demonstrates:
- Direct comparison: Regular proxy vs Web Unlocker
- Automatic CAPTCHA solving and fingerprinting
- No manual header/cookie configuration needed
Run it:
# Default runs with Web Unlocker enabled
npm run unlocker
# To try with Regular Datacenter Proxy:
# Set USE_WEB_UNLOCKER = false in the script, then run:
npm run unlockerDefault Configuration:
USE_WEB_UNLOCKER:true(Web Unlocker enabled by default)NUM_REQUESTS:10
Note: Script now uses axios for consistency with other HTTP scripts.
4. Scraping Browser (remote_browser.js)
What it demonstrates:
- Remote browser with automatic unique fingerprints
- Connects via WebSocket to Bright Data's hosted browsers
- Automatic CAPTCHA solving
- Chrome DevTools integration
Run it:
npm run remote-browserConfiguration:
USE_SCRAPING_BROWSER- Toggle between remote and local browserCOUNTRY- Target country for IP geolocationDELAY_BEFORE_CLOSE- Time to inspect in DevTools
Default Configuration:
USE_SCRAPING_BROWSER:false(starts in local Chrome mode)COUNTRY:'in'(India)DELAY_BEFORE_CLOSE:60000(60 seconds)
5. SERP API Demo (serp_api_demo.js)
What it demonstrates:
- Search engine scraping via Bright Data SERP API
- Supports Google, Bing, and DuckDuckGo
- Automatic JSON parsing with
brd_json=1 - Country and language targeting for Google searches
- Uses Bearer token authentication (not proxy credentials)
Run it:
npm run serpConfiguration:
SEARCH_QUERY- The search term to querySEARCH_ENGINE- Which engine to use:"google","bing", or"duckduckgo"USE_JSON_PARSING- Toggle structured JSON output vs raw HTMLCOUNTRY- Country code for geo-targeting (Google only)LANGUAGE- Language code for results (Google only)NUM_REQUESTS- Number of parallel requests
Default Configuration:
SEARCH_QUERY:"web scraping tutorial"SEARCH_ENGINE:"google"USE_JSON_PARSING:true(returns structured JSON)COUNTRY:"us"LANGUAGE:"en"NUM_REQUESTS:5
Note: SERP API uses direct API calls with Bearer token, not proxy-based requests.
Defined in package.json:
{
"scripts": {
"simple": "node src/simple_request.js",
"browser": "node src/browser_with_proxy.js",
"unlocker": "node src/unlocker_demo.js",
"remote-browser": "node src/remote_browser.js",
"serp": "node src/serp_api_demo.js"
}
}- Popular HTTP client with promise support
- Proxy configuration built-in
- Perfect for simple HTTP scraping
- Browser automation library by Google Chrome team
- Controls Chrome/Chromium via DevTools Protocol
- Excellent for JavaScript-heavy sites
- HTTPS proxy support for Node.js HTTP clients
- Integrates seamlessly with axios
- Used by all HTTP-based scripts for proxy connections
npm install- Check your
BRIGHTDATA_CUSTOMER_IDin.env - Verify zone names match your Bright Data dashboard
- Ensure passwords are correct (no extra spaces)
Update the executablePath in scripts:
- Windows:
C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe - Mac:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome - Linux:
/usr/bin/google-chrome
- Check internet connection
- Verify zone is active in Bright Data dashboard
- Try increasing timeout value in script
| Feature | JavaScript | Python |
|---|---|---|
| HTTP Library | axios | aiohttp |
| Browser Automation | Puppeteer | Playwright |
| Async Support | async/await | async/await |
| Performance | Fast | Fast |
| Learning Curve | Easy | Easy |
Both implementations follow the same workshop structure and concepts!
- Start with simple_request.js to understand proxy basics
- Toggle headers/cookies to see their impact
- Try browser_with_proxy.js for JavaScript-heavy sites
- Test unlocker_demo.js to see Web Unlocker in action
- Use serp_api_demo.js for search engine scraping
- Use remote_browser.js for maximum success rates
Happy Scraping with JavaScript! 🚀
For conceptual learning and decision frameworks, see the main README