Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
Puppeteer code to respect robots.txt file

This seems to be possible in Scrapy Scrapy and respect of robots.txt but is there a simple way to do this in Puppeteer?

I haven't found an easy way to build in "respect the Robots" into Puppeteer commands.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I don't believe puppeteer has anything built in but you can use puppeteer to access robots.txt and then use any of a number of npm modules to parse robots.txt to see if you're allowed to get any particular URL. For example, here's how you might use robots-txt-parser:

const robotsParser = require('robots-txt-parser')
const robots = robotsParser()

// Now inside an async function
// (or not if using a version of Node.js that supports top-level await)

await robots.useRobotsFor('https://example.com/')
if (await robots.canCrawl(urlToVisit)) {
  // Do stuff with puppeteer here to visit the URL
} else {
  // Inform the user that sadly crawling that URL is forbidden
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!