【发布时间】:2015-10-06 15:31:30
【问题描述】:
我有Files.txt,其中包含 Excel 文件的 URL 列表:
http://www.bcheadset.ca/applicant.xlsx
http://www.bcheadset.ca/fte.xlsx
http://www.iutox.org/TRTF_Matrix2012_Oct.xlsx
http://www.journalprices.com/2013_FinalSummaryForWeb.xlsx
http://www.camts.org/7__2013_Aircraft_Checklist.xlsx
http://www.nanotr11.org/poster_program.xlsx
http://www.vliruos.be/media/6352100/nss2015_annex_3_budget.xlsx
...
我想做的是(通过 wget)下载大于10Mo 的文件。
要在下载文件之前验证文件是否大于10Mo,我们可以使用curl --head。例如,curl --head http://www.bcheadset.ca/fte.xlsx 返回
HTTP/1.1 200 OK
Content-Length: 3158847
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Last-Modified: Mon, 27 Jul 2015 22:16:45 GMT
Accept-Ranges: bytes
ETag: "ffb49fecb9c8d01:c05"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 06 Oct 2015 15:14:27 GMT
而从Content-Length,我们可以验证它大于10Mo。
我的问题是如何通过Bash 或Perl 自动执行此操作。特别是我不知道如何提取Content-Length并进行比较...
有人可以帮忙吗?
【问题讨论】:
标签: bash perl shell web-scraping web-crawler