溫馨提示×

shell curl怎么獲取返回?cái)?shù)據(jù)

小億
550
2024-03-19 16:45:38
欄目: 編程語言

使用curl命令可以獲取返回?cái)?shù)據(jù)。以下是一個簡單的示例:

curl https://example.com/api/endpoint

在這個例子中,curl命令將發(fā)送一個GET請求到https://example.com/api/endpoint,并返回該請求的響應(yīng)數(shù)據(jù)。

如果您希望將返回?cái)?shù)據(jù)保存到文件中,可以使用-o選項(xiàng):

curl -o output.txt https://example.com/api/endpoint

這將把返回?cái)?shù)據(jù)保存到output.txt文件中。

如果您希望在終端中查看返回?cái)?shù)據(jù)而不保存到文件中,可以使用-o選項(xiàng):

curl https://example.com/api/endpoint

這將在終端中顯示返回?cái)?shù)據(jù)。

0