How to use the internetarchive.search function in internetarchive

To help you get started, we’ve selected a few internetarchive 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 leonardr / olipy / olipy / ia.py View on Github external
def search(cls, query, collection=None, fields=None, sorts=None, *args, **kwargs):
        """Search Internet Archive items.
        :param fields: Retrieve these metadata fields for each item. List of
            fields: https://archive.org/services/search/v1/fields
            By default, 'title', 'publidate', and 'identifier' are retrieved.
        :param sorts: A list of fields to use as sort order. Add
            " asc" or " desc" to the name of the field to specify
            ascending or descending order.
        """
        fields = fields or []
        for mandatory in ['title', 'publicdate']:
            if not mandatory in fields:
                fields.append(mandatory)
        query = cls.modified_query(query, collection)
        search = ia.search.Search(
            cls.session(), query, *args, fields=fields, sorts=sorts,
            **kwargs
        )
        for i in search.iter_as_results():
            yield cls(i)
github leonardr / cce-python / ia-0-search.py View on Github external
def _search(cls, query, *args, **kwargs):
        """Search Internet Archive items."""
        fields = cls.FIELDS
        sorts = ["date asc"]
        query = query + " and mediatype:texts"
        search = ia.search.Search(
            cls.session(), query, *args, fields=fields, sorts=sorts,
            params=dict(count=100, page=1),
            **kwargs
        )
        try:
            for i in search.iter_as_results():
                yield i
        except Exception as e:
            print(e)
            return
github leonardr / cce-python / ia-0-list-texts.py View on Github external
def search(cls, query, *args, **kwargs):
        """Search Internet Archive items."""
        fields = cls.FIELDS
        sorts = ["date asc"]
        query = query + " and mediatype:texts"
        search = ia.search.Search(
            cls.session(), query, *args, fields=fields, sorts=sorts,
            params=dict(count=10000),
            **kwargs
        )
        for i in search.iter_as_results():
            yield i