Skip to content

Commit 526f70e

Browse files
committed
Add example of saving a site as a PDF
1 parent e355e2d commit 526f70e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import base64
2+
from seleniumbase import SB
3+
from selenium.webdriver.common.print_page_options import PrintOptions
4+
5+
with SB(uc=True, test=True, ad_block=True) as sb:
6+
url = "https://seleniumbase.io"
7+
sb.activate_cdp_mode(url)
8+
sb.reconnect() # To access WebDriver methods
9+
print_options = PrintOptions()
10+
pdf_base64 = sb.driver.print_page(print_options)
11+
with open("downloaded_files/sb.pdf", "wb") as f:
12+
f.write(base64.b64decode(pdf_base64))

0 commit comments

Comments
 (0)