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
5 Replies
boiling-coffee•2y ago
for stopping, you can simply call
await crawler.teardown()
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
@CherryPapa just advanced to level 1! Thanks for your contributions! 🎉
boiling-coffee•2y ago
you need to read the documentation first,there's a tutorial in it too for beginners
@CherryPapa
can this article:
https://docs.apify.com/academy/node-js/analyzing-pages-and-fixing-errors
+ some generic stuff here:
https://www.altcademy.com/blog/how-to-throw-an-error-in-javascript/
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