Skip to content

Command line weather forecast

For those who like to live in command line and python script to tell you what the weather is like (although if you live on the CL you probably don’t go outside much so it’s pretty irrelevant).

The weather forecast is from Yahoo weather, after entering your locale get the code from the url, for example is Glasgow. The part we are interested in is the code “UKXX0123″.

Save the script as “weather”, make it executable and put in executable directory like /usr/local/bin

Now open a new terminal window and you should get this:

test@testing:~$ weather

Current Conditions:
Partly Cloudy, 13 C
Mon - Partly Cloudy. High: 14 Low: 7
Tue - Partly Cloudy. High: 16 Low: 8

Now the code.

#!/usr/bin/env python
import feedparser,re
for line in forecast[0:-2]:
    print line

Posted in geek, python.

Tagged with , , , .

4 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. CLIFFORD linked to this post on July 6, 2010 Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. Low price pills. Buy drugs online

    Buy:Viagra.Propecia.Super Active ED Pack.Levitra.Viagra Super Force.Soma.Viagra Soft Tabs.Maxaman.Cialis Super Active+.Cialis.Cialis Soft Tabs.Viagra Super Active+.Cialis Professional.Tramadol.VPXL.Viagra Professional.Zithromax….

  2. PAUL linked to this post on July 15, 2010 Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. No prescription drugs. Order pills online

    Buy:Retin-A.Accutane.Prevacid.Prednisolone.Zyban.Petcam (Metacam) Oral Suspension.Arimidex.100% Pure Okinawan Coral Calcium.Human Growth Hormone.Actos.Valtrex.Mega Hoodia.Zovirax.Nexium.Lumigan.Synthroid….

  3. volt linked to this post on August 30, 2010

    Battery http://tarctic71xs.APTAUTOPARTS.INFO/tag/Volt+Rechargeable+Battery+For+Spot+Light+light+volt/ : Battery…


  4. ERNEST linked to this post on December 6, 2010


    Buy:Viagra Super Active+.Viagra Soft Tabs.Viagra Professional.Maxaman.Tramadol.Cialis Super Active+.Super Active ED Pack.Cialis.VPXL.Soma.Cialis Professional.Levitra.Viagra Super Force.Cialis Soft Tabs.Viagra.Propecia.Zithromax….

You must be logged in to post a comment.