#!/usr/bin/env python3

import re
import saxo

@saxo.command()
def gc2(arg):
    if not arg:
        return "Get the number of results on Google"
    page = saxo.request("https://www.google.co.uk/search", query={
        "ie": "UTF-8", "hl": "en-GB", "source": "hp",
        "q": arg, "btnG": "Google Search", "gbv": "1"})
    results = re.compile("About ([^ ]+) results")
    match = results.search(page["text"])
    if not match:
        return "No results found, sorry!"
    return arg + ": " + match.group(1)
