开发者

Intercepting Wget output

开发者 https://www.devze.com 2023-02-01 06:28 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消