Quickly grab and copy HTML & CSS source to the clipboard with curl

Apr 9, 2011 - 4 Comments

This should be a helpful tip for the web developers out there. Using curl and pbcopy, we can quickly grab and copy HTML and CSS code from any URL via the command line.

Getting HTML is just a matter of pointing curl to the URL in question:

curl "http://google.com/" | pbcopy

The HTML will now be in your clipboard for you to paste anywhere else.

Grabbing the CSS requires you to specify where the CSS file is located, otherwise the command is the same:

curl "http://google.com/css/stylesheet.css" | pbcopy

We’ve covered pbcopy & pbpaste a while ago, they’re just command line interfaces for the Mac OS X clipboard but combined with other scripts or utilities can be quite powerful.

If you want to go a step further, you can also quickly mirror a website locally using wget or backup through FTP with wget.

Related articles:

Posted by: David Mendez in Command Line

4 Comments

» Comments RSS Feed

  1. Chuck says:

    you could use this for more than html and css

  2. [...] involved with the web should get some good use out of the header trick, and web developers can also use curl to copy all the HTML and CSS from a website very quickly. stLight.options({ [...]

  3. [...] Line, Tips & Tricks – July 16th, 2011 – Leave a Comment Using curl we can retrieve the HTML & CSS source code of any specified URL and even the http header info, but some sites serve completely [...]

  4. ubru bey says:

    how thoughtful..making it easy to everyone huh..thanks this would help.:)

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

OSXDaily on Facebook

OSXDaily on Google+

Shop at Amazon

Ad

Shared on Facebook