Skip to content

Commit 92fa132

Browse files
authored
Merge pull request #864 from ScrapeGraphAI/857-browserbase__init__-got-an-unexpected-keyword-argument-project_id
2 parents f383e72 + 752a885 commit 92fa132

File tree

1 file changed

+12
-40
lines changed

1 file changed

+12
-40
lines changed

scrapegraphai/docloaders/browser_base.py

+12-40
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,30 @@ def browser_base_fetch(api_key: str, project_id: str, link: List[str],
1111
1212
This module provides an interface to the BrowserBase API.
1313
14-
The `browser_base_fetch` function takes three arguments:
15-
- `api_key`: The API key provided by BrowserBase.
16-
- `project_id`: The ID of the project on BrowserBase where you want to fetch data from.
17-
- `link`: The URL or link that you want to fetch data from.
18-
- `text_content`: A boolean flag to specify whether to return only the
19-
text content (True) or the full HTML (False).
20-
- `async_mode`: A boolean flag that determines whether the function runs asynchronously
21-
(True) or synchronously (False, default).
22-
23-
It initializes a Browserbase object with the given API key and project ID,
24-
then uses this object to load the specified link.
25-
It returns the result of the loading operation.
26-
27-
Example usage:
28-
29-
```
30-
from browser_base_fetch import browser_base_fetch
31-
32-
result = browser_base_fetch(api_key="your_api_key",
33-
project_id="your_project_id", link="https://example.com")
34-
print(result)
35-
```
36-
37-
Please note that you need to replace "your_api_key" and "your_project_id"
38-
with your actual BrowserBase API key and project ID.
39-
4014
Args:
4115
api_key (str): The API key provided by BrowserBase.
4216
project_id (str): The ID of the project on BrowserBase where you want to fetch data from.
43-
link (str): The URL or link that you want to fetch data from.
44-
text_content (bool): Whether to return only the text content
45-
(True) or the full HTML (False). Defaults to True.
46-
async_mode (bool): Whether to run the function asynchronously
47-
(True) or synchronously (False). Defaults to False.
17+
link (List[str]): The URLs or links that you want to fetch data from.
18+
text_content (bool): Whether to return only the text content (True) or the full HTML (False).
19+
async_mode (bool): Whether to run the function asynchronously (True) or synchronously (False).
4820
4921
Returns:
50-
object: The result of the loading operation.
22+
List[str]: The results of the loading operations.
5123
"""
52-
5324
try:
5425
from browserbase import Browserbase
5526
except ImportError:
56-
raise ImportError(f"""The browserbase module is not installed.
57-
Please install it using `pip install browserbase`.""")
27+
raise ImportError("The browserbase module is not installed. Please install it using `pip install browserbase`.")
5828

59-
60-
browserbase = Browserbase(api_key=api_key, project_id=project_id)
29+
# Initialize client with API key
30+
browserbase = Browserbase(api_key=api_key)
31+
32+
# Create session with project ID
33+
session = browserbase.sessions.create(project_id=project_id)
6134

6235
result = []
6336
async def _async_fetch_link(l):
64-
return await asyncio.to_thread(browserbase.load, l, text_content=text_content)
37+
return await asyncio.to_thread(session.load, l, text_content=text_content)
6538

6639
if async_mode:
6740
async def _async_browser_base_fetch():
@@ -72,7 +45,6 @@ async def _async_browser_base_fetch():
7245
result = asyncio.run(_async_browser_base_fetch())
7346
else:
7447
for l in link:
75-
result.append(browserbase.load(l, text_content=text_content))
76-
48+
result.append(session.load(l, text_content=text_content))
7749

7850
return result

0 commit comments

Comments
 (0)