Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright with Chromium when a website needs real browser rendering: install Playwright and its browser binaries, navigate to the URL, then call page.pdf(). For pages that suit a direct HTML-to-PDF workflow, WeasyPrint can convert a URL with HTML(url).write_pdf(...). The documented steps are general Python instructions; the India qualifier does not add a special conversion step.

Choose the Python method that fits the page

Method Use it when Important consideration
Playwright with Chromium The page depends on browser behavior or you need browser PDF controls. Install the Python package and browser binaries. PDFs use print CSS by default; switch to screen media if needed. Playwright library guide and Page API.
WeasyPrint A direct URL-to-PDF conversion model suits the page. Its documentation warns that untrusted HTML/CSS and unrestricted access to local or remote resources can pose security risks. WeasyPrint 70.0 First Steps.
Requests You need to fetch HTTP content as one part of a larger pipeline. Requests documents HTTP access, not browser rendering or a URL-to-PDF converter. It is not a complete converter by itself. Requests documentation.

For browser-dependent pages, start with Playwright. A PDF is a rendering of the page, not a guarantee that every live interaction or dynamic element will be reproduced. Check the resulting PDF for styling and assets.

Convert a URL with Playwright and Chromium

Install Playwright and Chromium

  1. Install the Python package: python -m pip install playwright.
  2. Download the browser binaries: python -m playwright install chromium. The Playwright guide documents installing the package and running playwright install; Playwright supports Chromium, Firefox, and WebKit. See the guide.

Save the page as a PDF

Save this as url_to_pdf.py, replacing the example URL with the page you want to save:

import asyncio
from pathlib import Path
from playwright.async_api import async_playwright

async def main():
    url = "https://example.com"
    output = Path("page.pdf")

    async with async_playwright() as playwright:
        browser = await playwright.chromium.launch()
        page = await browser.new_page()
        response = await page.goto(url, wait_until="networkidle", timeout=60_000)

        if response is not None and not response.ok:
            raise RuntimeError(f"Page returned HTTP {response.status}: {url}")

        await page.pdf(path=str(output), format="A4", print_background=True)
        await browser.close()

    print(f"Saved {url} to {output.resolve()}")

asyncio.run(main())

Run it with python url_to_pdf.py. Playwright’s page.pdf() uses print CSS by default. Its API documentation states that it generates a PDF of the page with print CSS media. Page API details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose print or screen styling

Print media is the default and may use a site’s print-specific styles. If the PDF should resemble the screen version instead, emulate screen media before calling page.pdf():

await page.emulate_media(media="screen")
await page.pdf(path="page.pdf", format="A4", print_background=True)

CSS and loaded assets can affect the output. Inspect the PDF, particularly when a site hides elements for printing or loads content after the initial page response.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Convert a URL with WeasyPrint

WeasyPrint’s documented direct-URL pattern is concise. Install the package and any platform dependencies required by its installation instructions, then run:

from weasyprint import HTML

HTML("https://example.com").write_pdf("page.pdf")

The documented example uses HTML('https://weasyprint.org/').write_pdf('/tmp/weasyprint-website.pdf'). Consult the WeasyPrint 70.0 First Steps documentation for setup and API details. This route may be appropriate where its rendering support fits the page; it should not be assumed to behave like a full browser for sites reliant on browser-side behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Be careful with URLs and untrusted input

When converting arbitrary URLs or user-provided HTML/CSS in a server-side application, resource loading matters. WeasyPrint warns that untrusted HTML or CSS and unrestricted access to local or remote resources can create security problems. Restrict what the converter can access and constrain resource fetching for the application’s threat model; do not expose a conversion endpoint that blindly fetches arbitrary resources.

Why Requests alone does not make a PDF

Requests can retrieve HTTP content, and its documentation covers features such as timeouts and automatic content decoding. It does not document browser rendering or PDF generation. A response fetched with Requests is HTML or another HTTP resource, not a rendered PDF; use a renderer such as Playwright or WeasyPrint for the conversion step. Requests documentation.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Or skip the browser setup

ScreenshotNeo is a screenshot API and MCP server. Its endpoint returns screenshots or PDFs, so a Python request can save a URL as PDF without installing a local browser:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com", "format": "pdf"},
    timeout=90,
)
r.raise_for_status()
open("page.pdf", "wb").write(r.content)

See the ScreenshotNeo API documentation for authentication and supported parameters. Cookie banners, popups and chat widgets are removed before the shot; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common conversion problems

  • Playwright says the browser executable is missing: install the browser binaries with python -m playwright install chromium.
  • The PDF looks different from the on-screen page: page.pdf() uses print media by default. Try await page.emulate_media(media="screen") before generating the PDF, then inspect the result.
  • Content or images are absent: the page may load assets after navigation or use browser-dependent behavior. Check the PDF after capture; adjust the navigation wait or page readiness handling for the site rather than assuming the first response contains the finished page.
  • The script reports a non-success HTTP response: inspect the URL and response status. The sample raises an error for a response with a non-OK status instead of silently saving an error page.
  • WeasyPrint cannot fetch an asset or URL: check that the resource is reachable from the execution environment and that resource-access restrictions permit it. Do not remove security controls indiscriminately for untrusted input.
  • Requests returns HTML instead of a PDF: that is expected; Requests handles HTTP exchanges, not page rendering or PDF creation. Pass content to a suitable renderer or use Playwright.

India-specific considerations

The documented Python tooling steps above do not change for India. The sources cited here do not establish India-specific legal rules for saving arbitrary web pages, so this guide makes no jurisdiction-specific compliance claim. If the intended use raises legal or rights questions, consult an authoritative India-specific source relevant to that use.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Frequently Asked Questions

Can I use Requests by itself to convert a website URL to PDF?

No. Requests fetches HTTP resources; it does not provide browser rendering or PDF generation. Use a rendering library for the conversion.

Does the PDF preserve every interactive feature of a website?

No. A PDF is a rendered document, so inspect it for dynamic content, CSS differences and missing assets.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.