Am new to python, So i started trying simple codes in python.
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,ptitle)
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,ptitle)
print '%s' %(purl)
print '%s' %(pdes)
print '\n'
i +=1
------------------------------------------------------------------------------------------------------------------------------
Sample output 1:
avinash@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
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
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
England bowler Stuart Broad is confident England have all the "attributes" to beat Australia in the upcoming Ashes Test series.
No comments:
Post a Comment