Hi,
How do you use specifics headers in Base.download
to simulate Chrome usage?
I have found this curl example and I have tried to replicate it with the latest Chrome user-agent for Linux. However, when trying to specify the headers
keyword argument described in the user guide, I am told that there is no such thing. What is the correct syntax? I am defining the headers via Dict("user-agent" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36")
. Also, I have to specify the download folder.
I think I figured. Base.download
has been deprecated since 1.6 and you should use Downloads.download
. Also, in order to avoid potential 403 errors, you probably want to use something like this:
headers = Dict(
"User-Agent" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
"Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Accept-Language" => "en-GB,en;q=0.5",
"Accept-Encoding" => "gzip, deflate, br",
"Connection" => "keep-alive",
"Upgrade-Insecure-Requests" => "1",
"Sec-Fetch-Dest:" => "document",
"Sec-Fetch-Mode:" => "navigate",
"Sec-Fetch-Site:" => "none",
"Sec-Fetch-User:" => "?1"
)
Downloads.download(url, headers=headers);