News.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:jasper-modules 作者: mattcurrycom 项目源码 文件源码
def handle(text, mic, profile):

    if 'INDIA' in text:
        url = 'http://news.google.com/news?pz=1&cf=all&ned=in&hl=en&output=rss'
    elif 'CRICKET' in text:
        url = 'http://www.espncricinfo.com/rss/content/story/feeds/6.xml'
    elif 'TECH' in text:
        url = 'http://www.theregister.co.uk/headlines.atom'
    else:
        url = 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss'

    feed = feedparser.parse(url)
    if not feed:
        mic.say("I'm sorry. I could not get the news for you")
        return

    mic.say("Here is the headline news")
    for post in feed.entries:
        mic.say(post.title)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号