File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
- #!/usr/bin/env python3
2
-
3
- # pipenv --three
4
- # pipenv install requests mistletoe
5
- # pipenv run ./checklinks.py README.md
1
+ # /// script
2
+ # dependencies = [
3
+ # "requests==2.32.3",
4
+ # "mistletoe==1.4.0",
5
+ # ]
6
+ # ///
6
7
7
8
import sys
8
9
from mistletoe import Document , span_token , ast_renderer
14
15
FAILURE_EMOJI = unicodedata .lookup ('Cross Mark' )
15
16
16
17
if len (sys .argv ) != 2 :
17
- print ('Usage: pipenv run ./ checklinks.py README.md' )
18
+ print ('Usage: uv run checklinks.py README.md' )
18
19
sys .exit (1 )
19
20
20
21
urls = []
@@ -40,7 +41,10 @@ def walk(token):
40
41
session .headers .update ({'User-Agent' : USER_AGENT })
41
42
for url in urls :
42
43
try :
43
- r = session .get (url )
44
+ r = session .get (url , timeout = 10 )
45
+ except requests .exceptions .ReadTimeout :
46
+ print (f'{ FAILURE_EMOJI } { url } connection timeout' )
47
+ continue
44
48
except requests .exceptions .ConnectionError :
45
49
print (f'{ FAILURE_EMOJI } { url } connection error' )
46
50
continue
You can’t perform that action at this time.
0 commit comments