File size: 536 Bytes
34097e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from itertools import islice

try:
    from duckduckgo_search import DDGS
except ImportError:
    raise ImportError(
        "duckduckgo_search is required to image search. Please install it with `pip install --upgrade duckduckgo_search`."
    )


async def imageSearch(keywords="cute cats"):
    with DDGS() as ddgs:
        return [x for x in islice(ddgs.images(keywords), 30)]


if __name__ == "__main__":

    async def main():
        result = await imageSearch()
        print(result)

    import asyncio

    asyncio.run(main())