Nerdabout: the art and craft of technology

Using Lynx to Scrape a Weather Report

November 03, 2009

Lynx As A Simple HTML Parser

One great and often-overlooked feature of Lynx is its --dump option.

lynx --dump <url> dumps the text content of the Web page at URL, followed by a numbered list of URLs that were referenced in that page.

how to use Lynx to scrape a weather forecast

As demonstrated by the screenshot above, you can use Lynx to retrieve the weather forecast for a zip code.

In this case I used grep -A 26 to limit the output shown to just 26 relevant lines.

But if I had wanted to retrieve the entire forecast page, as plain text, the basic syntax is then just:

lynx --dump http://www.weather.com/weather/local/10013

Note that this same recipe can be used to retrieve the weather forecast for any US zip code. Just replace 10013 in any of the examples above, with the zip code of your choice.

The Nerdabout bloggers are (from left to right) Elizabeth Suman, John Son, Heather Quinlan, Joanna Burgess, Noah Sussman and Dave Caputo.
nerdabout group photo

@Nerdabout on Twitter

Please wait while our tweets load…

Or visit the Nerdabout's Twitter.

Advertisement

Nerdabout's TumbleBlog

Currently listening to…

David Caputo is rockin out to…

Noah Sussman listens to…

Nerdabout on Flickr

Joanna Burgess on Flickr


Noah Sussman on Flickr


Dave Caputo on Flickr


Heather Quinlan on Flickr


Elizabeth Suman on Flickr


John Son on Flickr

SITE SEARCH
SUBSCRIBE TO OUR NEWSLETTERS
CREDITS Photos: iStockphoto | Getty Images | AP | Wikipedia | DCL |
DISCOVERY SITES Discovery Channel / TLC / Animal Planet / Discovery Health / Science Channel / Planet Green / Discovery Kids / Military Channel /
Investigation Discovery / HD Theater / Turbo / FitTV / HowStuffWorks / TreeHugger / Petfinder / PetVideo / Discovery Education
SHOP Toys / Games / Telescopes / DVD Sets / Planet Earth DVD Sets / Gift Ideas
CUSTOMER SERVICE Viewer Relations / Free Newsletters / RSS /
CORPORATE Discovery Communications, Inc / Advertising / Careers @ Discovery / Privacy Policy / Visitor Agreement
ATTENTION! We recently updated our privacy policy. The changes are effective as of Tuesday, October 30, 2007. To see the new policy, click here. Questions? See the policy for the contact information.