I have a .php file that I would like wget to download, it will display a 4 digit number. Is there anyway to retrieve this output without wget echoing to an external file, a开发者_Go百科nd then reading the external file and deleting the external file.
Something like..
OUTPUT=`wget www.google.com`
print $OUTPUT
where it would get the text of google.com
Are you using UNIX? You can tell wget to be quiet (i.e. not print status info) and pipe the document to stdout easily:
wget -q -O /dev/stdout <URL>
(note that's a capital letter "O")
Not sure of a Windows way, but this means you get just the HTML document written to stdout, which you can then use within scripts...
curl will do what you want out of the box:
OUTPUT=$(curl www.google.com)
echo $OUTPUT
精彩评论