Open in CodeSandbox, sign in with GitHub, then fork the repository to begin making changes.
This project demonstrates how to use Bright Data's asynchronous Unlocker API to access websites through Bright Data Unlocker API.
This script helps you access websites with anti-bot protection or CAPTCHAs by using Bright Data's Web Unlocker to automatically bypass these obstacles.
- Select the
.env
file - Add the following variables:
Alternatively, edit the CONFIG object directly in the script:
const CONFIG = {
apiToken: process.env.BRIGHT_DATA_API_TOKEN || 'YOUR_API_TOKEN', // Replace with your actual token
zone: process.env.BRIGHT_DATA_ZONE || 'web_unlocker1', // Replace with your zone
targetUrl: 'https://geo.brdtest.com/welcome.txt' // Replace with your target URL
};
- Make sure you've configured your
API token
andzone
- Run
node index.js
in the terminal - Check the console output for the results
- The script makes a POST request to Bright Data's Unlocker API endpoint
- It includes your authentication token and target URL
- Bright Data's Web Unlocker accesses the target URL
- The response is returned to your script and displayed in the console
If you encounter errors:
- Verify your API token is correct
- Check that your zone name is valid
- Ensure your target URL is properly formatted
To request a different URL:
- Update the
targetUrl
in the CONFIG object - Run the script again
Note: This is an example implementation for educational purposes. For production use, consider adding additional error handling, logging, and security measures.