URL中的空格导致wget失败

Sri*_*ram 2 bash wget

我有一个像这么网址:
http://localhost:8999/createAudio?method=createAudio&sessionId=1234&text=${line}&voice=Paul&encoder=MP3";
哪里${line}是"这是这样一个美好的一天."
wget用来捕获上面的http请求的输出,如下所示:
cURL="http://localhost:8999/createAudio?method=createAudio&sessionId=1234&text=${line}&voice=Sangeeta&encoder=MP3";
wget -O test.html ${cURL}

我的问题是http请求在第一个空白区域切断.因此,将发出的http请求将如下所示:
http://localhost:8999/createAudio?method=createAudio&sessionId=1234&text=This

如何确保${line}在http请求中使用整个?

Joh*_*ess 7

一个答案是简单地将空格进行URL编码%20,除去任何文字空间.

但是,wget会为你做这件事.这里你的问题是你在初始化cURL变量时正确引用了,但是当你在curl命令行中实际使用它时却没有.你还需要在那里引用,否则bash会将该变量中的任何空格解释为参数分隔符:

wget -O test.html "$cURL"
Run Code Online (Sandbox Code Playgroud)