How to stop aria2 from renaming HTML files?

I am using aria2 and uGet (which is a GUI for aria2) to download files, however it renames the HTML files, for example I download this link https://www.wowhead.com/item=10001 and it saves the file renamed as "black-mageweave-robe" (without extension).

I need the downloaded file to have a name like "item=10001" (without extension), just like the name you get when using wget

I am using Windows, but I guess they act the same on Linux too.


Solution 1:

aria2 does not rename the files, wget does - more about that later. aria2 does not have a way to automatically behave like wget on every download, but you can get the name you want by creating a download list with options (note the mandatory whitespace before the option):

https://www.wowhead.com/item=10001
 out=item=10001
https://www.wowhead.com/item=10002
 out=item=10002

Then use the file as an input:

aria2c -i files.txt

If you are using aria2 you probably have a lot of files to download and is already generating a list of files using some sort of script, so this should not be that difficult. A clever text editor could also do this with a good search-and-replace operation.

Why wget lies to you

When you try to download item=10001 the server informs you that there is no such path on the server. However, it helpfully tells us:

HTTP/1.1 301 Moved Permanently
Location: /item=10001/black-mageweave-robe

A plain browser will follow the redirect and - according to the HTTP standard - will update the URI to match. wget does retry the new location but pretends the redirect never happens and uses the old name. I personally think this is a flaw in wget, which just so happened to meet your requirements in this case!

You can have wget use the new location with the --trust-server-names flag.