#!/usr/bin/env python3

# http://inamidst.com/saxo/
# Created by Sean B. Palmer

import urllib.parse
import saxo

@saxo.command()
def news(arg):
    url = "https://www.bing.co.uk/news/search?q=" + urllib.parse.quote(arg)
    page = saxo.request(url)
    text = page["text"]
    if 'newstitle"><a href="' in text:
        a, b = text.split('newstitle"><a href="', 1)
        return b.split('"', 1)[0]
    return "Sorry, no news about that"
