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

When a page’s data is created or fetched by JavaScript, Python’s requests client sees only the initial HTTP response—not necessarily what a browser displays. First check whether the data is already in that response. If it is, parse it directly; if not, use Playwright or Selenium to run the page’s JavaScript, wait for the specific content or data response you need, and parse that result.

Decide whether you need a browser

Do not start with browser automation by default. A page may look dynamic while its useful content is already present in the original HTML. Fetch the page with an HTTP client and inspect the response first. If the required text or structured data is there, parse it with an HTML parser such as BeautifulSoup. That approach avoids launching a browser and is usually simpler to operate.

If the initial response is only an application shell, or the page fetches records after navigation or a user action, a plain HTTP request will not execute that JavaScript. You then need either to reproduce the underlying data request or automate a browser. Browser automation is the more direct route when the page requires interaction; capturing the relevant JSON response can be more robust when the site exposes one.

  • Initial HTML contains the data: use an HTTP client and parse the response.
  • JavaScript renders or fetches the data: use a browser, or identify and reproduce the data request.
  • The data appears only after an action: automate that action, then wait for the resulting content or response.

Install a Python browser and parser

This walkthrough uses Playwright’s synchronous Python API with Chromium and BeautifulSoup. Install the Python packages and then the browser binary:

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.
  1. python -m pip install playwright beautifulsoup4
  2. python -m playwright install chromium

Run those commands in the same Python environment that will run your script. The browser installation step matters: installing the Playwright package alone does not guarantee that Chromium is available.

Capture rendered HTML with Playwright

The example below opens a page, performs a user action, waits for a result element, and parses matching elements from the rendered DOM. Replace the example URL, button name, and selector with ones that describe the actual page. The selectors are illustrative, not guaranteed to match any particular site.

from playwright.sync_api import sync_playwright
from bs4 import BeautifulSoup

URL = "https://example.com"

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page()

    try:
        page.goto(URL, wait_until="domcontentloaded", timeout=30_000)
        page.get_by_role("button", name="Load more").click(timeout=10_000)
        page.locator("article.result").first.wait_for(state="visible", timeout=15_000)

        html = page.content()
        soup = BeautifulSoup(html, "html.parser")
        rows = [
            node.get_text(" ", strip=True)
            for node in soup.select("article.result")
        ]

        if not rows:
            raise RuntimeError("The page loaded, but no result elements were found")

        for row in rows:
            print(row)
    finally:
        browser.close()

page.content() gives you the current page HTML after the action and readiness check. BeautifulSoup can then handle familiar parsing tasks such as selecting elements, extracting text, and normalizing whitespace. If your application can use Playwright locators directly, you can also read text or attributes from those locators rather than serializing the page to HTML first.

Choose the right navigation and readiness condition

domcontentloaded waits for the initial document to be parsed, but it does not mean a modern application has finished fetching and rendering its data. load waits for the page’s load event, which may also occur before later application work finishes. For scraping, the best signal is usually the content you intend to collect: wait for its locator, an expected value, or the response that supplies it.

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

Playwright also supports navigation states including commit and networkidle. The latter is explicitly discouraged for testing in Playwright’s Page documentation; pages can keep background connections active, and network quiet does not prove that the target content is ready. Avoid replacing a real readiness check with a fixed sleep unless you have a specific, justified delay to handle.

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.

Handle pagination and repeated actions

For a “Load more” button, click and wait for a meaningful change—such as a new result count, a new item, or a response carrying the next page. For numbered pagination, identify the next-page control and wait for the new page’s expected content. Keep track of already processed records so retries or repeated clicks do not silently duplicate output. Stop when the site indicates there are no more results, rather than assuming a fixed number of pages.

Capture the data response instead of parsing the DOM

When the page loads records through an XHR or fetch request, the response may contain structured JSON that is easier to parse and less dependent on the site’s CSS layout. Playwright can wait for a matching response while you reproduce the action that triggers it:

with page.expect_response("**/api/results") as response_info:
    page.get_by_role("button", name="Load more").click()

response = response_info.value
payload = response.json()
print(payload)

Use the actual endpoint pattern observed for the target page; **/api/results is only an example. Confirm the request method, query parameters, authentication requirements, pagination behavior, and response shape before relying on the endpoint. A response listener can tell you what the browser received, but it does not establish that you are authorized to access or collect that data.

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

If you can call the data endpoint directly, you may not need a browser for every run. Reproduce only the necessary request and validate its response. Be prepared for tokens, cookies, changing parameters, or other requirements that make the browser session part of the site’s intended flow.

Choose between Playwright and Selenium

Both Playwright and Selenium provide Python APIs for browser interaction. The right choice depends on your existing setup and the synchronization and network-inspection features your task needs; there is no universal speed winner established here.

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.
Consideration Playwright Selenium
Readiness and locators Provides locator-based waiting and explicit navigation states. Provides browser interaction through the WebDriver API; synchronization depends on the approach you implement.
Requests and responses Offers request and response monitoring, including a way to wait for a matching response. Suitable for browser automation; whether its surrounding setup meets a network-interception need depends on your ecosystem and tooling.
Existing infrastructure A natural fit when you want its Python API and browser hooks in one workflow. A natural fit when your team already uses WebDriver, a grid, or Selenium expertise.
Decision point Consider it for locator-driven synchronization and direct network-response hooks. Consider it when compatibility with an established WebDriver environment matters most.

Assess browser coverage, deployment constraints, debugging workflow, and how you will keep browser binaries and drivers available in your runtime. The documentation describes APIs, not a controlled head-to-head benchmark for your workload.

Validate results instead of trusting a successful page load

A page can navigate successfully and still yield an empty or incomplete dataset. Treat the result as valid only after checking that the expected structure and fields are present. For example, verify a nonzero record count when records are expected, check required fields, and distinguish an empty state intentionally shown by the site from a failed or premature capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Use selectors tied to the target content, not broad selectors that can match unrelated page elements.
  • Normalize text deliberately with whitespace handling such as BeautifulSoup’s get_text(" ", strip=True).
  • Log the URL, readiness condition, record count, and a useful error when expected data is missing.
  • Make layout changes fail visibly: validate key fields instead of silently accepting empty strings or missing nodes.
  • For network-derived data, validate the response status and expected JSON keys before processing records.

Timeouts, reliability, and responsible collection

Set explicit timeouts for navigation and interactions, sized for the target site and your runtime. A timeout should produce a diagnosable failure, not an unbounded wait. Handle redirects, HTTP errors, login requirements, pagination boundaries, and transient failures deliberately. Retry only errors that may be transient, and use a bounded retry policy so a persistent block or broken selector does not create an endless loop.

Dynamic pages can render incrementally after the browser’s load event, so a content-specific readiness condition is more reliable than assuming navigation completion means collection is complete. Where available, the actual data response reduces dependence on changing CSS markup. These choices improve robustness, but they do not remove the need to monitor selector changes, application behavior, or changes to an endpoint.

Respect the site’s terms, robots guidance, access controls, privacy obligations, and rate limits. Browser automation is not permission to collect a site’s data. Keep request volume appropriate, especially when iterating through multiple pages or retrying failed operations.

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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

requests returns an empty shell or misses the visible data

Cause: The initial HTTP response does not contain content that JavaScript fetches or creates later. Fix: Inspect the response first; if the needed data is absent, automate the browser and wait for its content, or capture and validate the data response that supplies it.

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

The script times out waiting for a selector

Cause: The selector may be wrong, the page may require another action, the content may be hidden, or navigation may not have reached the expected state. Fix: Confirm the selector in the rendered page, verify the action and page state, and wait for the correct visible element or data response. Do not simply increase the timeout without checking the cause.

The script prints zero records after a successful navigation

Cause: Navigation completion is not the same as data readiness; the page might need a click, pagination step, or different selector. Fix: Wait for a target-specific condition, inspect the rendered HTML, and validate whether the records instead arrive in a JSON response.

networkidle never arrives or arrives before the data

Cause: Background requests can keep a page active, while network quiet alone does not establish that the desired data rendered. Fix: Use a locator, assertion, or matching response tied to the content you need.

Chromium will not launch

Cause: The Playwright package may be installed without the corresponding browser binary, or the runtime may not have the required browser available. Fix: Install Chromium with python -m playwright install chromium in the environment used by the script, then inspect the launch error for any runtime-specific dependency issue.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

The browser sees records but parsing returns blanks

Cause: The selector may target a wrapper without text, the data may be in attributes or nested elements, or the content may not yet be rendered when HTML is captured. Fix: Inspect the captured HTML, target the element that contains the value, and extract the appropriate text or attribute after the readiness check.

Or skip the browser setup

If the job is to capture a page as an image or PDF rather than extract individual fields, ScreenshotNeo is a website screenshot API and MCP server for developers. A single GET request accepts a URL; its clean-capture steps can accept consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture, with each step configurable. See the ScreenshotNeo overview and API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -o shot.webp

Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Screenshot capture is not a substitute for parsing records or a way around access controls.

Sign up for free: 1,000 screenshots a month, no card required.

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

References

Frequently Asked Questions

Can I use BeautifulSoup to execute JavaScript?

No. BeautifulSoup parses HTML; pair it with an HTTP client for static responses or a browser automation tool when JavaScript must run.

Does a rendered screenshot give me structured page data?

No. A screenshot is a visual capture. Extracting fields requires parsing rendered HTML or a data response.

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.