使用wget和相同的base-url的多个发布请求

wget有很好的select,可以让你从同一个位置下载多个文件

(我的意思是--base--input-file组合)

这样做的好处是,如果可能的话wget尝试重用打开的套接字/连接。

我想知道是否有可能使用wget做多个POST请求。 (我可能最终写在python中,因为我不能在wget的文档中find这种用法)

即在input文件内我会有发布数据(json在我的情况):

 {"results":1} {"results":2} 

并要求如下:

 wget --header "Content-Type: application/json" -i input.data http://example.com/api/data 

我认为你正在寻找--post-file参数。 -i用于GET方法(提供URL列表),而不是POST

 wget --header "Content-Type: application/json" --post-file input.data http://example.com/api/data 

你可以参考手册页

另一种可能是使用curl

 curl -H "Content-Type: application/json" -X POST -d @input.data http://example.com/api/data 

你可以参考手册页