开发者

Can not retrieve a url using curl

While trying to retrieve the URL http://www.kat.ph/search/snow-patrol-shut-your-eyes/?categories%5B%5D=music using curl I am getting an error which says

curl: (3) [globbing] illegal character in range specification at pos 65

Why is that so开发者_如何学Go ? while [ seems to be a perfectly valid character in the browser address bar ,how can i retrieve the same url in curl ?


You can use the -g option to stop curl from globbing itself. It will then pass the URL with [] to the server as-is.


curl http://www.kat.ph/search/snow-patrol-shut-your-eyes/?categories%5B%5D=music

works fine for me. Is that actually what you're using? Or do you have the [ in your curl string?

Update

Yeah, I get the same error on curl http://www.kat.ph/search/snow-patrol-shut-your-eyes/?categories[]=music. Your browser silently encodes the [] for you when it makes the request (browsers allow users to be lazy). cURL expects you to be able to encode for yourself, so characters like [], space, etc. need to be encoded first. Take a look at this tool to encode or decode a URL http://meyerweb.com/eric/tools/dencoder/


You can escape the [ and ] characters as follows \[ and \]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜