Fetching Pages
A URL is the name of a page on the network. Curl fetches the page and prints it.
Fetch a page
Curl -s stays silent. The page comes back as text.
$ cd ~/practice
$ curl -s https://example.com | headSave the page
Wget -q stays silent. The -O option names the file.
$ cd ~/practice
$ wget -q -O page.html https://example.com
$ ls -l page.html
$ head page.htmlExample
$ cd ~/practice
$ wget -q -O example-page.html https://example.com
$ ls -l example-page.html
$ curl -s https://example.com | headKey points
- A download is a copy of a page saved on this machine.
- Use curl to fetch a page and print it.
- Use wget to download a page into a file.
- head shows the first lines of a page.
- Your page may look different from the page shown here.
In this example, wget saves the page as example-page.html. The size shows the file landed. Curl then fetches the same page and prints it.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does wget -q -O page.html https://example.com do?