File tree Expand file tree Collapse file tree 1 file changed +0
-24
lines changed
Expand file tree Collapse file tree 1 file changed +0
-24
lines changed Original file line number Diff line number Diff line change 11import os
22import requests
33import logging
4- from urllib .parse import urlparse
5-
6- ALLOW_403_FOR = {
7- d .strip ().lower ()
8- for d in os .getenv ("ALLOW_403_FOR" , "" ).split ("," )
9- if d .strip ()
10- }
114
125def check_url (url : str , timeout : int = 10 ) -> dict :
136 """Return dict with url, status, status_code, error."""
147 try :
158 r = requests .get (url , timeout = timeout )
16- host = urlparse (url ).hostname or ""
17- host = host .lower ()
18-
19- print (f"URL: { url } , host: { host } , ALLOW_403_FOR: { ALLOW_403_FOR } " )
20-
219 if r .status_code == 200 :
2210 return {"url" : url , "status" : "Success" , "status_code" : 200 , "error" : None }
23-
24- if r .status_code == 403 :
25- print ("🔥🔥🔥 inside 403 block" , host )
26- if host .endswith ("substack.com" ) or host == "substack.com" :
27- print ("✅ Substack override triggered" )
28- return {
29- "url" : url ,
30- "status" : "Success (403 allowed)" ,
31- "status_code" : 403 ,
32- "error" : None
33- }
34-
3511 return {
3612 "url" : url ,
3713 "status" : f"HTTP { r .status_code } " ,
You can’t perform that action at this time.
0 commit comments