Closed ssardina closed 1 year ago
I think tinyrul resets the connection after realizing that there were many consecutive requests
We can fix this by catching the exception, waiting 1 second, and then re-trying:
# TinyURL shortener service
def shorten_url(url):
s = pyshorteners.Shortener()
try:
return s.tinyurl.short(url)
# except:
# return s.dagd.short(url)
except: # in case of error, wait 1 second and try again
time.sleep(1)
return shorten_url(url)
a bit of a hack but it is OK in this situation.
When building the dataframe for teamapps, function
phq_club.to_teamsapp_schedule
crashes after calling the shorten url tinyurl service repetitively: