Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解析包含json选项的url?_Json_Curl_Uri - Fatal编程技术网

如何解析包含json选项的url?

如何解析包含json选项的url?,json,curl,uri,Json,Curl,Uri,正如标题所说,我正在尝试解析一个url,如下所示: https://salzundbrot.com/suche/#!search={"s1":60,"s2":90,"r1":2,"r2":4,"f1":450,"f2":750,"c":3}&x=1&view=infotiles curl抛出以下错误: $ curl https://salzundbrot.com/suche/#!search={"s1":60,"s2":90,"r1":2,"r2":4,"f1":450,"f2

正如标题所说,我正在尝试解析一个url,如下所示:

https://salzundbrot.com/suche/#!search={"s1":60,"s2":90,"r1":2,"r2":4,"f1":450,"f2":750,"c":3}&x=1&view=infotiles
curl抛出以下错误:

$ curl https://salzundbrot.com/suche/#!search={"s1":60,"s2":90,"r1":2,"r2":4,"f1":450,"f2":750,"c":3}&x=1&view=infotiles
-bash: !search={/"s1/": event not found
ruby的uri模块也不能处理它,抛出一个错误的uri不是uri吗?错误


单引号不起作用,转义双引号不起作用-当然有办法做到这一点,但我找不到它。

正如我在上面所评论的,如果URL中包含哈希或片段标识符中的数据,即后面的部分,因为URL的这一部分不是通过curl或web浏览器发送到服务器的。给定一个URL,如http://example.com/!foo=bar,curl将仅请求http://example.com/. 根据RFC-3986,片段标识符在解引用之前与URI的其余部分分离,因此片段本身中的标识信息仅由用户代理解引用

但是,对于其他URL,可以使用带有xargs的herdeoc。Curl的-globoff选项阻止它解释括号或大括号,否则foo{bar,baz}将使Curl发出两个请求,一个请求foobar,一个请求foobaz


这“有效”,因为它返回了一些东西,但只是胡言乱语。我会把我实际使用的url放在这里,这样你就可以自己看到了。我已经忘记了curl用大括号的行为。我已经更新了我的答案。使用这种URL,您不会得到预期的结果。URL中以散列或片段标识符开头的部分不会通过curl发送到服务器,它只会请求https://somesite.com/search/. 根据,片段标识符在取消引用之前与URI的其余部分分离,因此片段本身中的标识信息仅由用户代理取消引用。这很公平-感谢您的时间!
$ xargs <<END curl --globoff
https://somesite.com/search/?search={"s1":55,"s2":90,"r1":2,"r2":4,"f1":450,"f2":775,"c":3}&x=1
END