linux - 如何处理 wget 下载链接中的特殊字符?

标签 linux ssh terminal

我有一个这样的链接:

 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

但是虽然密码授权没问题,wget还是无法处理链接。为什么?

最佳答案

处理链接时最安全的方法浏览器是使用单引号(')来引用整个链接字符串。这样 shell 就不会尝试分解它,而无需您手动转义每个特殊字符:

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'

或者,举个真实的例子:

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'

请记住,服务器端限制可能会使像这样使用 wget 变得相当困难。例如,谷歌禁止某些用户代理字符串,因此上面的 --user-agent 选项。其他服务器使用 cookie 来维护 session 信息,简单地向 wget 提供链接是行不通的。 YMMV.

关于linux - 如何处理 wget 下载链接中的特殊字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25461361/

相关文章:

java - 在一个命令中提取多个 jar

python - 使用 Python 3 和终端检索蓝牙设备列表

linux - Ubuntu 14.04 终端损坏

linux - 在下一行的空白区域下方重复第一行中第一列的值

mercurial - 如何为单个 hg 存储库设置多个 ssh 身份?

mercurial - hg 存档到远程目录

bash - 我如何使用Expect通过ssh连接到系统并更改主机系统的密码?

linux - 在Linux上的正则表达式中,*指的是

linux - 如何在调用 shell 执行一串命令时运行 pkill?

ruby - 就地进度输出到控制台 : How to empty the current line