download
download(count: int, path: str = "./img", threads: int = 1) -> bool
download(count: int, path: str = "./img", threads: int = 1) -> bool
The download
method allows you to download images found as a result of a search.
Parameters:
count
(int): The number of images to download.path
(str): The path to the directory where the downloaded images will be saved. Default is"./img"
.threads
(int): The number of threads to use for downloading the images. Default is 1 thread.
Description:
If the search result type is "images"
, the method calls the download_images
method from the Threads
class, passing the path, image count, and thread count as parameters.
If the result type is not "images"
, the method returns False
.
Example Usage:
from searchx import Client
client = Client()
# Assuming we have image search results
results = client.search("cute cats", type="images", pages=2)
# Downloading images
success = results.download(count=15, path="./my_images", threads=4)
if success:
print("Images successfully downloaded.")
else:
print("Error downloading images.")
How the Method Works:
The method checks the search result type.
If the type is "images"
, it initiates the image download process, passing the necessary parameters.
It returns True
if the download started successfully, or False
if the type is not "images"
.
Return Value:
The method returns True
if the image download starts successfully, or False
for other types of data.
Last updated