我已经了解到,我们可以使用CURL发送多个HTTP请求:
curl -I http://linuxbyexample.co.nr http://lne.blogdns.com/lbe
或这个:
xargs curl -I < url-list.txt
我们怎样才能把所有的答案都保存下来 – 每一个答案都是不同的文件?
您可以使用-o
命令行选项将输出写入文件而不是stdout。 你可以使用多个例如
curl -I http://linuxbyexample.co.nr lbe.co.nr.txt http://lne.blogdns.com/lbe -o lne.txt
如果你像这样格式化你的urls-list.txt
http://serverfault.com -o serverfault.com.txt http://example.com -o example.com.txt
它应该如你所愿地工作。
$ cat urls-list.txt http://linuxbyexample.co.nr http://lne.blogdns.com/lbe $ while read u; do \ curl -I $u -o $(echo $u | sed 's/http:\/\///' | tr '/' '_').header; \ done < urls-list.txt $ cat linuxbyexample.co.nr.header HTTP/1.1 200 OK Date: Thu, 24 Nov 2011 03:15:19 GMT Server: LiteSpeed Connection: close X-Powered-By: PHP/5.2.10 Content-Type: text/html X-Powered-By: PleskLin