@@ -226,7 +226,7 @@ def __init__(
226
226
* ,
227
227
api_key : Optional [str ] = None ,
228
228
api_url : Optional [str ] = None ,
229
- mode : Literal ["crawl" , "scrape" , "map" , "extract" ] = "crawl" ,
229
+ mode : Literal ["crawl" , "scrape" , "map" , "extract" , "search" ] = "crawl" ,
230
230
params : Optional [dict ] = None ,
231
231
):
232
232
"""Initialize with API key and url.
@@ -242,6 +242,7 @@ def __init__(
242
242
"crawl" (all accessible sub pages),
243
243
"map" (returns list of links that are semantically related).
244
244
"extract" (extracts structured data from a page).
245
+ "search" (search for data across the web).
245
246
params: The parameters to pass to the Firecrawl API.
246
247
Examples include crawlerOptions.
247
248
For more details, visit: https://github.com/mendableai/firecrawl-py
@@ -253,10 +254,10 @@ def __init__(
253
254
raise ImportError (
254
255
"`firecrawl` package not found, please run `pip install firecrawl-py`"
255
256
)
256
- if mode not in ("crawl" , "scrape" , "search" , "map" , "extract" ):
257
+ if mode not in ("crawl" , "scrape" , "search" , "map" , "extract" , "search" ):
257
258
raise ValueError (
258
259
f"""Invalid mode '{ mode } '.
259
- Allowed: 'crawl', 'scrape', 'search', 'map', 'extract'."""
260
+ Allowed: 'crawl', 'scrape', 'search', 'map', 'extract', 'search' ."""
260
261
)
261
262
262
263
if not url :
@@ -293,13 +294,14 @@ def lazy_load(self) -> Iterator[Document]:
293
294
str (self .firecrawl .extract ([self .url ], params = self .params ))
294
295
]
295
296
elif self .mode == "search" :
296
- raise ValueError (
297
- "Search mode is not supported in this version, please downgrade."
297
+ firecrawl_docs = self .firecrawl .search (
298
+ query = self .params .get ("query" ),
299
+ params = self .params ,
298
300
)
299
301
else :
300
302
raise ValueError (
301
303
f"""Invalid mode '{ self .mode } '.
302
- Allowed: 'crawl', 'scrape', 'map', 'extract'."""
304
+ Allowed: 'crawl', 'scrape', 'map', 'extract', 'search' ."""
303
305
)
304
306
for doc in firecrawl_docs :
305
307
if self .mode == "map" or self .mode == "extract" :
0 commit comments