Home > bash > Download a webpage and print it to the standard output

Download a webpage and print it to the standard output

Problem
You want to download a webpage and print its content to the standard output. For instance you want to push it through a pipe for further processing.

Solution
The easiest way is to use “curl” since by default it prints the downloaded content to the stdout:

curl http://www.python.org | less

You might want to add the switch “-s” to make curl silent, i.e. hide the progress bar.

With “wget” it’s a bit more complicated:

wget -qO- http://www.python.org | less

If you want to add syntax highlighting to less, see this post.

References
Redirecting wget to STDOUT – now with Syntax Highlighting

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: