我正在嘗試卷曲一個接受正則運算式作為引數之一的 API。
我發現 curl 在這里試圖變得聰明并且決議正則運算式本身,而不是將其視為 URL 的一部分。因此,每次我啟動 curl 命令時,它都會繼續發出 70,000 個 HTTP 請求。它應該只制作一個。
例子: https://api.example.com/v1/?regex=(123[4-5][6-7][8-9])
在這種情況下,我希望文字 HTTP 請求是那個.
相反,我得到:
[1/8]: https://api.example.com/v1/?regex=(123468) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123468)
curl: (6) Could not resolve host: api.example.com
[2/8]: https://api.example.com/v1/?regex=(123469) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123469)
curl: (6) Could not resolve host: api.example.com
[3/8]: https://api.example.com/v1/?regex=(123478) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123478)
curl: (6) Could not resolve host: api.example.com
[4/8]: https://api.example.com/v1/?regex=(123479) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123479)
curl: (6) Could not resolve host: api.example.com
[5/8]: https://api.example.com/v1/?regex=(123568) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123568)
curl: (6) Could not resolve host: api.example.com
[6/8]: https://api.example.com/v1/?regex=(123569) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123569)
curl: (6) Could not resolve host: api.example.com
[7/8]: https://api.example.com/v1/?regex=(123578) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123578)
curl: (6) Could not resolve host: api.example.com
[8/8]: https://api.example.com/v1/?regex=(123579) --> <stdout>
--_curl_--https://api.example.com/v1/?regex=(123579)
curl: (6) Could not resolve host: api.example.com
如何禁用 curl 具有的此正則運算式決議?
我查了一下curl --help all,沒有關于這種決議的內容。我還檢查了 curl 的手冊頁。那里也什么都沒有;這似乎是一個完全沒有記錄的“有用”功能。
它似乎是 curl,而不是 shell,因為 wget 似乎不會發生這種情況,它只生成一個(請求失敗)。
試圖轉義括號\似乎會阻止決議,但也會以一種看起來不正確的方式轉換字符:
root@voip:/tmp# wget "https://api.example.com/v1/?regex=(123\[4-5\]\[6-7\]\[8-9\])"
--2021-11-05 11:26:03-- https://api.example.com/v1/?regex=(123\[4-5\]\[6-7\]\[8-9\])
Resolving api.example.com (api.example.com)... failed: Name or service not known.
wget: unable to resolve host address ‘api.example.com’
root@voip:/tmp# wget "https://api.example.com/v1/?regex=(123\[4-5]\[6-7]\[8-9])"
--2021-11-05 11:26:25-- https://api.example.com/v1/?regex=(123\[4-5]\[6-7]\[8-9])
Resolving api.example.com (api.example.com)... failed: Name or service not known.
wget: unable to resolve host address ‘api.example.com’
uj5u.com熱心網友回復:
要使用 {} 和 [] 禁用 URL 序列和范圍,您可以使用 option -g。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/350837.html
上一篇:替換資料框列中空字典的值
