File tree Expand file tree Collapse file tree 2 files changed +4
-10
lines changed Expand file tree Collapse file tree 2 files changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,13 @@ def load_urls(self, urls: List[str]):
37
37
"wss://api.browserbase.com?apiKey=" + self .api_key
38
38
)
39
39
40
- html_contents = []
41
40
for url in urls :
42
41
page = browser .new_page ()
43
42
page .goto (url )
44
- html = page .content ()
45
- html_contents .append (html )
46
- page .close ()
43
+ yield page .content ()
47
44
48
45
browser .close ()
49
46
50
- return html_contents
51
-
52
47
def screenshot (self , url : str , full_page : bool = False ):
53
48
"""Load a page in a headless browser and return a screenshot as base64 string"""
54
49
if not url :
Original file line number Diff line number Diff line change @@ -12,13 +12,12 @@ def test_load(self):
12
12
self .assertIn ("Example Domain" , result )
13
13
14
14
def test_load_urls (self ):
15
- result = self .browserbase .load_urls (["https://example.com" ])
16
- self .assertIn ("Example Domain" , result [ 0 ] )
15
+ result = next ( self .browserbase .load_urls (["https://example.com" ]) )
16
+ self .assertIn ("Example Domain" , result )
17
17
18
18
def test_screenshot (self ):
19
19
result = self .browserbase .screenshot ("https://example.com" )
20
- print (result )
21
- self .assertIn ("Example Domain" , result )
20
+ self .assertIn ("oq0IBiQAAAABJRU5ErkJggg==" , result )
22
21
23
22
24
23
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments