Some websites and CDNs are increasingly disallowing connections from non-browser-looking entities. This results in some false positive from URL checking as 403 is returned to htmlproofer, but the link is valid if opened from a browser.
I've had success adding a user-agent in the past like this:
req = urllib.request.Request(
url,
headers={
# Mimic a web browser to bypass certain CDN 403 blocking.
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36"
},
)
Some websites and CDNs are increasingly disallowing connections from non-browser-looking entities. This results in some false positive from URL checking as
403is returned tohtmlproofer, but the link is valid if opened from a browser.I've had success adding a user-agent in the past like this: