search
search(query: str, type: str = "search", pages: int = 1) -> Search
search(query: str, type: str = "search", pages: int = 1) -> Search
The search
method allows you to perform search queries through Google and return results for both standard web search and image search.
Parameters:
query
(str): The search query string.type
(str): The type of search, default is"search"
. You can set"images"
for image search.pages
(int): The number of result pages to process. Default is 1 page.
Description:
For standard web search, search
returns a list of links to the found web pages and their brief descriptions.
For image search, the method retrieves links to the images.
Example Usage:
How the Method Works:
Web Search:
The method sends a GET request to Google with the specified query and collects links (url
) and descriptions (description
) for each result. It returns up to 10 results per page.
Image Search: The method sends a GET request to Google Images and collects image URLs. Each search page contains up to 35 images.
Note:
The method uses the
cloudscraper
library to bypass Cloudflare protection.The
user-agent
header is dynamically selected using thefake_useragent
library.
Return Value:
The method returns an instance of the Search
class, containing a list of search results with url
and description
fields.
Last updated