I\'m trying to use curl in bash to download a webpage, but the &
symbol in the URL isn\'t interpreted as a character as I would like. Any ideas on how I can
Putting the entire URL inside double quotes should take care of your problem.
Putting single quotes around the &
symbol seems to work. That is, using a URL like http://www.example.com/page.asp?arg1=${i}'&'arg2=${j}
with curl returns the requested webpage.
You can use %26
instead &
.
The entity code will work fine.
Instead of trying the escape "&" characters, you can specify http url parameters in POST requests with -d parameter as shown below:
curl -X POST http://www.example.com \
-d arg1=this \
-d arg2=that
If the request is a GET, then you should also add -G option, which tells curl to send the data with GET request.
curl -X GET -G http://www.example.com \
-d arg1=this \
-d arg2=that
Use the parameter --url
with double quotes worked for me
easiest way :
curl -X GET -G http://example.com -d var1=$1 -d var2=$2