コード例 #1
0
def search_author(name):
    """Looking for an author"""
    response = web.getXML("https://www.goodreads.com/api/author_url/%s?key=%s" %
                          (urllib.parse.quote(name), context.config["goodreadskey"]))
    if response is not None and len(response.getElementsByTagName("author")) and response.getElementsByTagName("author")[0].hasAttribute("id"):
        response = web.getXML("https://www.goodreads.com/author/show/%s.xml?key=%s" %
                              (urllib.parse.quote(response.getElementsByTagName("author")[0].getAttribute("id")), context.config["goodreadskey"]))
        if response is not None and len(response.getElementsByTagName("author")):
            return response.getElementsByTagName("author")[0]
    return None
コード例 #2
0
def get_book(title):
    """Retrieve a book from its title"""
    response = web.getXML("https://www.goodreads.com/book/title.xml?key=%s&title=%s" %
                          (context.config["goodreadskey"], urllib.parse.quote(title)))
    if response is not None and len(response.getElementsByTagName("book")):
        return response.getElementsByTagName("book")[0]
    else:
        return None
コード例 #3
0
def search_books(title):
    """Get a list of book matching given title"""
    response = web.getXML("https://www.goodreads.com/search.xml?key=%s&q=%s" %
                          (context.config["goodreadskey"], urllib.parse.quote(title)))
    if response is not None and len(response.getElementsByTagName("search")):
        return response.getElementsByTagName("search")[0].getElementsByTagName("results")[0].getElementsByTagName("work")
    else:
        return []
コード例 #4
0
def search_author(name):
    """Looking for an author"""
    response = web.getXML(
        "https://www.goodreads.com/api/author_url/%s?key=%s" %
        (urllib.parse.quote(name), context.config["goodreadskey"]))
    if response is not None and len(
            response.getElementsByTagName("author")
    ) and response.getElementsByTagName("author")[0].hasAttribute("id"):
        response = web.getXML(
            "https://www.goodreads.com/author/show/%s.xml?key=%s" %
            (urllib.parse.quote(
                response.getElementsByTagName("author")[0].getAttribute("id")),
             context.config["goodreadskey"]))
        if response is not None and len(
                response.getElementsByTagName("author")):
            return response.getElementsByTagName("author")[0]
    return None
コード例 #5
0
ファイル: velib.py プロジェクト: pombredanne/nemubot
def station_status(station):
    """Gets available and free status of a given station"""
    response = web.getXML(URL_API % station)
    if response is not None:
        available = int(response.getElementsByTagName("available")[0].firstChild.nodeValue)
        free = int(response.getElementsByTagName("free")[0].firstChild.nodeValue)
        return (available, free)
    else:
        return (None, None)
コード例 #6
0
def get_book(title):
    """Retrieve a book from its title"""
    response = web.getXML(
        "https://www.goodreads.com/book/title.xml?key=%s&title=%s" %
        (context.config["goodreadskey"], urllib.parse.quote(title)))
    if response is not None and len(response.getElementsByTagName("book")):
        return response.getElementsByTagName("book")[0]
    else:
        return None
コード例 #7
0
def search_books(title):
    """Get a list of book matching given title"""
    response = web.getXML(
        "https://www.goodreads.com/search.xml?key=%s&q=%s" %
        (context.config["goodreadskey"], urllib.parse.quote(title)))
    if response is not None and len(response.getElementsByTagName("search")):
        return response.getElementsByTagName("search")[0].getElementsByTagName(
            "results")[0].getElementsByTagName("work")
    else:
        return []
コード例 #8
0
ファイル: wolframalpha.py プロジェクト: nbr23/nemubot
 def __init__(self, terms):
     self.wfares = web.getXML(URL_API % quote(terms),
                              timeout=12)
コード例 #9
0
 def __init__(self, terms):
     self.wfares = web.getXML(URL_API % quote(terms), timeout=12)