我有一个文本文档,它包含了一堆这样格式的url:
URL = "sitehere.com"
我要做的是运行curl -K myfile.txt,并将curl返回的响应输出保存到一个文件中。
我该怎么做呢?
我有一个文本文档,它包含了一堆这样格式的url:
URL = "sitehere.com"
我要做的是运行curl -K myfile.txt,并将curl返回的响应输出保存到一个文件中。
我该怎么做呢?
当前回答
写入在指定文件中接收到的第一个输出(如果存在旧输出则覆盖)。
curl -K myconfig.txt >> output.txt
其他回答
如果您希望将输出存储到桌面,请使用git bash中的post命令执行以下命令。这对我很管用。
curl https://localhost:8080
--request POST
--header "Content-Type: application/json"
-o "C:\Desktop\test.json"
有点晚了,但我想他们想要的是:
curl -K myfile.txt --trace-ascii output.txt
有几个选项可以将curl输出到文件中
# saves it to myfile.txt
curl http://www.example.com/data.txt -o myfile.txt
# The #1 will get substituted with the url, so the filename contains the url
curl http://www.example.com/data.txt -o "file_#1.txt"
# saves to data.txt, the filename extracted from the URL
curl http://www.example.com/data.txt -O
# saves to filename determined by the Content-Disposition header sent by the server.
curl http://www.example.com/data.txt -O -J
您需要在“URL”-o“file_output”之间添加引号,否则,curl将无法识别URL或文本文件名。
格式
curl "url" -o filename
例子
curl "https://en.wikipedia.org/wiki/Quotation_mark" -o output_file.txt
Example_2
curl "https://en.wikipedia.org/wiki/Quotation_mark" > output_file.txt
一定要加上引号。
写入在指定文件中接收到的第一个输出(如果存在旧输出则覆盖)。
curl -K myconfig.txt >> output.txt