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

Is it possible to change the proxyUrl with the beforeRequest hook? #77

Open
szmarczak opened this issue Sep 11, 2022 · 4 comments
Open
Assignees

Comments

@szmarczak
Copy link
Contributor

Hey!

First off all thanks for this amazing package!

As the title suggests, is there any way to set the proxyUrl through the beforeRequest hook?
Ideally I'd like to do this on the beforeRetry hook but we cannot access the options object from there.

It should sort of act like a proxy rotation system - if the request fails, call a function which returns a new proxy and set it as the new proxyUrl.

Thanks!

Originally posted by @PhilBookst in #76

@szmarczak szmarczak self-assigned this Sep 11, 2022
@szmarczak
Copy link
Contributor Author

It should be possible to do that, I'll add a test for this. You should be able to override error.options.context.proxyUrl.

@VoidMonk
Copy link

VoidMonk commented Jul 7, 2023

Any way to remove the set proxy before a retry?

Setting error.options.context.proxyUrl to undefined, null or an empty string in the beforeRetry hook still makes a retry request with the originally set proxyUrl.

@szmarczak We'll appreciate any suggestions or unit test results from you. Thanks.

@yovanoc
Copy link

yovanoc commented Sep 23, 2023

Would like to know this too, thanks

@yovanoc
Copy link

yovanoc commented Jan 18, 2024

as I understand, if we extends the got-scraping client our hooks will be called after got-scraping ones, so the proxy hook is called before we can change the proxyUrl

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

3 participants