adverse-sapphire
adverse-sapphire•2y ago

How can stop crawler and return error when crawler get timeOutError?

I have created a module and intend to perform web scraping by calling a crawler in that module. If the specified selector cannot be collected during the scraping process, I want the crawler to stop and return the encountered error. I would like to check this error using a try/catch statement. Is there a solution? Or Can I get some test code about it? example code
const engine = ()=>{
try{
const crawler = const crawler = new PlaywrightCrawler({});
}catch(err){
//I want to catch here of crawler's error about timeout
}
}
const engine = ()=>{
try{
const crawler = const crawler = new PlaywrightCrawler({});
}catch(err){
//I want to catch here of crawler's error about timeout
}
}
5 Replies
boiling-coffee
boiling-coffee•2y ago
for stopping, you can simply call await crawler.teardown()
adverse-sapphire
adverse-sapphireOP•2y ago
Oh thank you , but i not just stop I want to know how to throw error. errorhandler can catch error but i don't know how to throw error
MEE6
MEE6•2y ago
@CherryPapa just advanced to level 1! Thanks for your contributions! 🎉
boiling-coffee
boiling-coffee•2y ago
you need to read the documentation first,there's a tutorial in it too for beginners
Oleg V.
Oleg V.•2y ago
How to analyze and fix errors when scraping a website | Academy | A...
Learn how to deal with random crashes in your web-scraping and automation jobs. Find out the essentials of debugging and fixing problems in your crawlers.
Altcademy Blog
How to throw an error in JavaScript
For anyone learning programming, encountering errors and debugging them is an inevitable part of the journey. In JavaScript, errors can be generated using the throw statement. In this blog post, we will explore how to throw errors in JavaScript, understand the types of errors, and learn about error handling using

Did you find this page helpful?