[BangPypers] Latest Cricket News in Command Line

Gopalakrishnan Subramani gopalakrishnan.subramani at gmail.com
Mon Oct 4 15:13:23 CEST 2010


I don't think, I will be giving you the complete working code, here is
sample one.

sites = {
0: "<<BBCLink>>",
1: "<<CricInfoLink>>"
}

X= input('BBC Cricket News:1 , Cricinfo Cricket News:2 \n enter your choice:
')

if sites.has_key((int(X)):
    news_feed = feedparser.parse(sites[int(X)])
    for entry in news_feed.entries:
          print "<<your format>>, entry.title, entry.description
           <<file the rest here>>

The above code may not work syntactically. Hope this helps.

If you are ever interested knowing the latest cricket news, here is the link
from my own site, http://stacked.in/cricket?section=sports
Certainly writing your own parser would help you to build your
knowledge..Have fun..

Regards,

Krish
http://stacked.in

On Sun, Oct 3, 2010 at 9:46 PM, Avinash TM <avinashtm at gmail.com> wrote:

> Hi All ,
> I tried this simple code using 'feed parser'. May be you will find it
> useful.
> Am new to Python,any suggestions or new ideas on how we can improve this
> code.
>
> -Avinash
>
>
>
>
> _______________________________________________________________________________________
> *
> *
> *Program : *
>
> #! /usr/bin/python
> import feedparser
>
> BBCCricketNews = feedparser.parse('
> http://newsrss.bbc.co.uk/rss/sportplayer_uk_edition/cricket/rss.xml')
> CricinfoCricketNews = feedparser.parse('
> http://www.cricinfo.com/rss/content/story/feeds/0.rss')
>
> X= input('BBC Cricket News:1 , Cricinfo Cricket News:2 \n enter your
> choice:
> ')
> i=1
>
> if X==1:
>  print "BBC Cricket news"
>  while i <= 5:
>        ptitle =  BBCCricketNews.entries[i].title
>        pdes=BBCCricketNews.entries[i].description
>        purl=BBCCricketNews.entries[i].link
>        print '%s.%s' %(i,a)
>        print '%s' %(purl)
>        print '%s' %(pdes)
>        print '\n'
>        i +=1
>
> elif X==2:
>  print "Cricinfo Cricket news"
>  while i <= 5:
>        ptitle=CricinfoCricketNews.entries[i].title
>        pdes=CricinfoCricketNews.entries[i].description
>        purl=CricinfoCricketNews.entries[i].link
>        print '%s.%s' %(i,a)
>        print '%s' %(purl)
>        print '%s' %(pdes)
>        print '\n'
>        i +=1
>
> ----------------------------------------------------------------------------------------------------------------------------------
> *Sample output 1:*
> avinash at linux-qqbq:~/pyPrograms> ./LatestCricketNews.py
> BBC Cricket News:1 , Cricinfo Cricket News:2
>  enter your choice: 1
> BBC Cricket news
> 1.Swann thrilled by 'dream' Ashes tour
> http://news.bbc.co.uk/go/rss/-/sport1/hi/cricket/9028868.stm
> Graeme Swann tells BBC Sport that a childhood dream has been realised after
> being named as part of England's squad for this winter's Ashes series in
> Australia.
>
>
> 2.Miller explains Ashes squad choices
> http://news.bbc.co.uk/go/rss/-/sport1/hi/cricket/9028456.stm
> England Chairman of selectors Geoff Miller says Ashes squad members Monty
> Panesar and Chris Tremlett derverve their place after improving their form
> in county cricket.
>
>
> 3.Broad confident of England victory
> http://news.bbc.co.uk/go/rss/-/sport1/hi/cricket/9027720.stm
> England bowler Stuart Broad is confident England have all the "attributes"
> to beat Australia in the upcoming Ashes Test series.
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list