File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 77import os
88import codecs
99import requests
10+ import time
1011
1112URLS = []
1213
13- def check_external_url (url ):
14+ def check_external_url (url , tries = 0 ):
15+ if tries > 10 :
16+ raise Exception (f"{ url } still 429ed after { tries } tries" )
1417 # only checking the local or github files
1518 # we may comment since later and check everything but it takes time
1619 if "spoon.forge" not in url and "INRIA/spoon" not in url : return
1720
1821 if url in URLS : return
1922 r = requests .get (url , headers = {"user-agent" : "Mozilla/5.0 FakeBrowser" }) # sf.net, elsevier use stupid UA detection
23+ if r .status_code == 429 :
24+ print ("Got 429, sleeping for a bit" )
25+ print (r .text )
26+ time .sleep (2 )
27+ return check_external_url (url , tries = tries + 1 )
2028 if r .status_code != 200 :
2129 raise Exception (url + " invalid " + str (r .status_code ))
2230 URLS .append (url )
You can’t perform that action at this time.
0 commit comments