How to use the akshare.wdbank.api.WBSearchResult function in akshare

To help you get started, we’ve selected a few akshare examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jindaxiang / akshare / akshare / wdbank / api.py View on Github external
"""
    if indicator:
        if source or topic:
            raise ValueError(INDIC_ERROR)
        query_url = "/".join((INDICATOR_URL, parse_value_or_iterable(indicator)))
    elif source:
        if topic:
            raise ValueError(INDIC_ERROR)
        query_url = "/".join(
            (SOURCES_URL, parse_value_or_iterable(source), "indicators")
        )
    elif topic:
        query_url = "/".join((TOPIC_URL, parse_value_or_iterable(topic), "indicators"))
    else:
        query_url = INDICATOR_URL
    return WBSearchResult(fetcher.fetch(query_url, cache=cache))
github jindaxiang / akshare / akshare / wdbank / api.py View on Github external
def id_only_query(query_url, query_id, cache):
    """
    Retrieve information when ids are the only arguments

    :query_url: the base url to use for the query
    :query_id: an id or sequence of ids
    :cache: use the cache
    :returns: WBSearchResult containing dictionary objects describing results
    """
    if query_id:
        query_url = "/".join((query_url, parse_value_or_iterable(query_id)))
    return WBSearchResult(fetcher.fetch(query_url))
github jindaxiang / akshare / akshare / wdbank / api.py View on Github external
def search_countries(query, incomelevel=None, lendingtype=None, cache=True):
    """
    Search countries by name.  Very simple search.

    :query: the string to match against country names
    :incomelevel: if present, search only the matching incomelevel
    :lendingtype: if present, search only the matching lendingtype
    :cache: use the cache
    :returns: WBSearchResult containing dictionary objects representing
        countries
    """
    countries = get_country(
        incomelevel=incomelevel, lendingtype=lendingtype, cache=cache
    )
    pattern = re.compile(query, re.IGNORECASE)
    return WBSearchResult(i for i in countries if pattern.search(i["name"]))
github jindaxiang / akshare / akshare / wdbank / api.py View on Github external
def search_indicators(query, source=None, topic=None, cache=True):
    """
    Search indicators for a certain regular expression.  Only one of source or
    topic can be specified. In interactive mode, will return None and print ids
    and names unless suppress_printing is True.

    :query: the term to match against indicator names
    :source: if present, id of desired source
    :topic: if present, id of desired topic
    :cache: use the cache
    :returns: WBSearchResult containing dictionary objects representing search
        indicators
    """
    indicators = get_indicator(source=source, topic=topic, cache=cache)
    pattern = re.compile(query, re.IGNORECASE)
    return WBSearchResult(i for i in indicators if pattern.search(i["name"]))