Closed Sayechtan closed 9 months ago
No. This error is raised by the server, because you are making too many requests. How long did your code got running?
Sometimes up to 90 minutes sometimes after 10 minutes. I cant rebuild it.
But are you using try-except
and trying the request again after some seconds? CloudflareError is very common to happen.
I think it's because of this for-loop:
for page_number_last in range(-10, 0):
airport_details = fr_api.get_airport_details(code=iata_code, page=page_number_last)
found_flight_list = find_list_of_flights(airport_details)
num_flights = len(found_flight_list)
time.sleep(15)
if num_flights == 100:
page_number_last -= 1
break
I'm doing this, because I want the last page number with 100 flights, to get all flights from the last day.
Try something like this on your code:
time_for_waiting = 15
punishment = time_for_waiting
for page_number_last in range(-10, 0):
try:
airport_details = fr_api.get_airport_details(code=iata_code, page=page_number_last)
found_flight_list = find_list_of_flights(airport_details)
except:
time.sleep(punishment)
punishment *= 1.5 # Increase +50%
continue
punishment = time_for_waiting
num_flights = len(found_flight_list)
time.sleep(time_for_waiting)
if num_flights == 100:
page_number_last -= 1
break
Thank you. I test it!
Did it work? I'm closing this issue for now. Open it again if you are still in trouble.
It's working! Thank you
I'm collecting all arrival flights to certain airports. After a while I get this error: "CloudflareError: An unexpected error has occurred. Perhaps you are making too many calls?"
I can't replicate it. I also read the errors provided in this Code. But i wasn't able to solve it. I also set a sleep timer to 30 seconds.
Is there any possibility, to avoid this error?