Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent being blacklisted and/or report exceptions #4

Open
jochemstoel opened this issue Aug 9, 2018 · 0 comments
Open

Prevent being blacklisted and/or report exceptions #4

jochemstoel opened this issue Aug 9, 2018 · 0 comments

Comments

@jochemstoel
Copy link

As the respective page layout may change, this approach is pretty fragile. Keep in mind that the respective platform may rate-limit / blacklist you in case of "excessive" usage.
Source: readme

I create unofficial APIs using request and cheerio all the time in the exact same way. What you can do to prevent getting blacklisted is cache the response body to the local file system and set a minimum delay time required before fetching it again. If cache is less than x period old, resolve local file and otherwise fetch it again and overwrite. This also protects the user if he or she is stupid and the script accidentally gets executed in a loop.

You don't want to periodically check if all of your modules like this 'still work'. You can implement a sort of event handler/callback at the end of your HTTP request logic that will report back to you if something failed. In other words, if successful do nothing but otherwise send the error somewhere using webhooks or websockets or something. Whether you want this depends on the situation or should be optional I guess but in this way when something changes that breaks your script, you will know about it in seconds from all users and applications using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant