Reputation: 5243
Suppose there is a text file link in a webpage. Now I can use HTML builder to parse the page, extract that link, and download that file into a directory of my choice through WGET. But is it possible to do a check on the file prior to downloading it? I mean, like checking the first 6 letters to find whether it matches the sequence cooler
, and if it does, only then download it?
Upvotes: 0
Views: 246
Reputation: 621
Read some of the file before downloading it?
You could use curl with its --range option to download part of the file. But you'd need to know enough about the file to skip any meta/header data I assume.
man curl
note, according to the man page:
You should also be aware that many HTTP/1.1 servers do not have this feature enabled, so that when you attempt to get a range, you'll instead get the whole document.
Upvotes: 4