Last Updated on 2023-12-05 by Clay
I shared a project for generating image by font file with Python, in my example code, I using wget
command to download an open-source font file.
But after two years, when I ran my code, I could not download the file.
wget https://www.1001freefonts.com/d/26673/atozimple.zip
Output:
--2022-07-25 15:54:00-- https://www.1001freefonts.com/d/26673/atozimple.zip Resolving www.1001freefonts.com (www.1001freefonts.com)... 172.66.43.121, 172.66.40.135, 2606:4700:3108::ac42:2b79, ... Connecting to www.1001freefonts.com (www.1001freefonts.com)|172.66.43.121|:443... connected. HTTP request sent, awaiting response... 302 Found Location: /atozimple.font [following] --2022-07-25 15:54:00-- https://www.1001freefonts.com/atozimple.font Reusing existing connection to www.1001freefonts.com:443. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: ‘atozimple.zip’ atozimple.zip [ <=> ] 53.69K --.-KB/s in 0.007s 2022-07-25 15:54:01 (7.40 MB/s) - ‘atozimple.zip’ saved [54982]
As you can see, my downloading is failed. In the first time I think the link is broken, but I tried to visit the website, I found the website to be functioning properly.
Verify in real browser, I check it will be re-direct to the website.
The solution is:
wget https://www.1001freefonts.com/d/26673/atozimple.zip --referer=https://www.1001freefonts.com/
HTTP Referer usually indicates the source address of the request. It may be to prevent abnormal or attacks, so the website administrator will check the Referer header. So when we add the --referer
parameter to the wget
command, it is actually used to simulate the browser's operation.
I searched Internet and found this solution, but the above explanation is generated by GPT-4, I think it could be refer but need to verify.
我有查詢到這個解決方法,但以上的說明為 GPT-4 所告知,可以作為參考但仍需驗證。