A headless browser is a web browser without a graphical user interface (GUI). It runs in the background, controlled programmatically through code or command-line interfaces. Headless browsers can perform all standard browser operations like rendering web pages, executing JavaScript, and handling cookies, but without displaying any visual components.
Common Use Cases
- Web scraping and data extraction
- Automated testing of web applications
- Taking screenshots or generating PDFs of web pages
- Performance monitoring and testing
- Automation of repetitive web tasks
Advantages
- Reduced resource consumption (no GUI rendering required)
- Faster execution than full browser instances
- Ideal for server environments without display capabilities
- Perfect for CI/CD pipelines and automated workflows
Headless browsers are commonly used in developer tools, testing frameworks, and automation services to interact with web content programmatically.
Headless example
// SDK will prepare the browser and will start it on your machine then you can control it with puppeteer
import { GologinApi } from 'gologin';
const token = process.env.GL_API_TOKEN || 'your dev token here';
const gologin = GologinApi({
token,
});
async function main() {
const { browser } = await gologin.launch({
extra_params: ['--headless'],
// pass profileId parameter if you want to run particular profile
// profileId: 'your profileId here',
});
const page = await browser.newPage();
await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
const status = await page.$eval('.trustworthy:not(.hide)',
(elt) => elt?.innerText?.trim(),
);
await new Promise((resolve) => setTimeout(resolve, 10000));
console.log('status', status);
return status;
}
main().catch(console.error)
.finally(gologin.exit);
Responses are generated using AI and may contain mistakes.