How to handle special characters in a wget download link?
11,718
The safest way when handling a link from e.g. a browser is to use single quotes ('
) to quote the whole link string. That way the shell will not try to break it up, without you having to manually escape each special character:
wget --user=user_nm --http-password=pass123 'https://site.domain.com/Folder/Folder/page.php?link=/Folder/Folder/Csv.Stock.php&namefile=STOCK.Stock.csv'
Or, for a real example:
wget --user-agent=firefox 'https://www.google.com/search?q=bash+shell+singl+quote&ie=utf-8&oe=utf-8&aq=t&rls=org.mageia:en-US:official&client=firefox-a#q=bash+single+quote&rls=org.mageia:en-US:official'
Keep in mind that server-side restrictions might make using wget
like this quite hard. Google, for example, forbids certain user agent strings, hence the --user-agent
option above. Other servers use cookies to maintain session information and simply feeding a link to wget
will not work. YMMV.
Author by
user2421781
Updated on June 05, 2022Comments
-
user2421781 almost 2 years
I have a link like this:
wget --user=user_nm --http-password=pass123 https://site.domain.com/Folder/Folder/page.php?link=/Folder/Folder/Csv.Stock.php\&namefile=STOCK.Stock.csv
But while the password authorization is fine,
wget
still cannot process the link. Why?