Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
public-apis
Commits
3979c871
Unverified
Commit
3979c871
authored
Oct 22, 2021
by
Dmytro Khmelenko
Committed by
GitHub
Oct 21, 2021
Browse files
Set host header for link validator (#2409)
parent
aff6b25f
Changes
1
Hide whitespace changes
Inline
Side-by-side
build/validate_links.py
View file @
3979c871
...
...
@@ -51,9 +51,16 @@ def validate_links(links):
for
link
in
links
:
h
=
httplib2
.
Http
(
disable_ssl_certificate_validation
=
True
,
timeout
=
25
)
try
:
# fetching host name, removing leading www
host
=
link
.
split
(
'//'
,
1
)[
1
].
split
(
'/'
,
1
)[
0
]
if
host
[:
3
]
==
'www'
:
host
=
host
[
4
:]
resp
=
h
.
request
(
link
,
headers
=
{
# Faking user agent as some hosting services block not-whitelisted UA
'user-agent'
:
'Mozilla/5.0'
'user-agent'
:
'Mozilla/5.0'
,
# setting host because Cloudflare returns 403 asking for captcha if host is missing
'host'
:
host
})
code
=
int
(
resp
[
0
][
'status'
])
# Checking status code errors
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment