Comments (10)
Hi @asciimoo do you have any example using your retry solution?
from colly.
c.OnError(func(resp *colly.Response, err error) {
resp.Request.Retry()
})
from colly.
bump on any example - since it helps give users a clear idea on how you intend users to use it.
from colly.
@xg-wang Currently this is not supported by default, but it's definitely a useful feature. It could be achieved by adding a Retry()
member function to the Request
object. What do you think?
from colly.
Or we can do it on [http_backend](https://github.com/gocolly/colly/blob/master/http_backend.go#L156)
level by adding another LimitRule.Retry.
from colly.
@xg-wang yes, that is another good approach, however it gives less flexibility to manage retries imo. If it is a part of the Request
object, then we are able to decide that on which returned status codes we want to perform further requests.
What are the benefits of extending LimitRule
?
from colly.
@asciimoo The Response has all the information that Request
have. By extending LimitRule
is more consistent as it already has Delay
and Parallelism
, it is quite natural to specify the retry attempt number here imo.
from colly.
By extending LimitRule is more consistent as it already has Delay and Parallelism, it is quite natural to specify the retry attempt number here imo.
LimitRule doesn't feel like the right place for me to handle request resubmission, since it is responsible for limiting requests and not to perform requests again.
What if we want to increase the delay between retries or just print a debug message on each retry? It doesn't seem to be achievable with the LimitRule
approach.
I've implemented the Request.Retry()
solution on branch retry
: 03c5f59 . It feels more intuitive and flexible for me so if you like this solution I'll merge it.
from colly.
I'm down for it. Looks good.
from colly.
@olivierpons thanks for the response. I did add retry logic once i due in a bit into the codebase. I wanted to limit the number of retries before i give up.
from colly.
Related Issues (20)
- Fetching data that is not coming in curl output HOT 1
- SIGSEG on local files HOT 1
- Misleading Request.Depth documentation HOT 1
- I have a request that I don't know how to make using Colly. HOT 1
- Different MaxDepth on AllowedDomains and others ? HOT 3
- Is there a way spider for "https://netbanking.hdfcbank.com/netbanking" with my owner account? HOT 1
- HTML encoding is not autodetected properly HOT 6
- request chan error HOT 1
- Cannot send request with no Accept header HOT 1
- handleOnXML tries to parse`.xlsx` files HOT 2
- Next release - When?
- Duplicated requests HOT 1
- How to handle selector not found?
- how to by pass c.OnError HOT 1
- Post Login not persist session
- Weird async behaviour - duplicates in responses HOT 1
- Support BFS search .
- retry redirect to AlreadyVisitedUrl will loop error HOT 1
- Error trying to conditionally set up proxy function HOT 1
- Can't provide duplicate key values when POSTing form data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from colly.