How do you get the source of the webpage from the terminal?

On my website, I have a text file with data in it (this site is hosted by GoDaddy so I can't access the file locally). This file is updated via PHP. From Unix / Linux / Mac bash, I would like to get the contents of a text file so that I can use it in scripts. Any help would be appreciated :)

+3


source to share


2 answers


curl

already installed on your Mac, so you don't need to install it. You will also find curl

it installed for almost any Linux distribution. This is probably your safest bet.

cd /Users/me/Desktop
curl www.google.com >> google.txt

      



wget

can be easily installed on your Mac using Homebrew . It will probably be installed on most Linux distributions already.

cd /Users/me/Desktop
wget www.google.com

      

+11


source


Install MacPorts and install wget

:

$ sudo port install wget

      

And then:



$ wget http://godaddy.com/somewhere/somefile.txt

      

And the resulting text file will be somefile.txt

(this can be changed with the option -O

).

+2


source







All Articles