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

关于失败后动态切换代理的问题 #1174

Open
YOHN89 opened this issue Aug 14, 2024 · 1 comment
Open

关于失败后动态切换代理的问题 #1174

YOHN89 opened this issue Aug 14, 2024 · 1 comment

Comments

@YOHN89
Copy link

YOHN89 commented Aug 14, 2024

需求:需要在抓取数据的请求超时之后,能自动切换到一个新的代理ip,因为在我们的场景下,代理ip是有时效的,存活大概就2~3分钟左右。看了很多文档和问题,推荐的做法是自定义一个proxyProvider来实现动态切换代理。
问题:我在proxyProvider里怎么才能能知道上次的请求已经超时了呢?

@sutra
Copy link
Collaborator

sutra commented Aug 15, 2024

returnProxy 的入参有 Page 和 Task,可以获得上次请求的情况:
us.codecraft.webmagic.proxy.ProxyProvider.returnProxy(Proxy, Page, Task)

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

2 participants