[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-post-python-web-scraping-javascript-en":3},{"post":4,"faq":34,"faqLdJson":60,"faqLdJsonScript":91,"alternatePaths":92,"recommendations":94,"contentLocale":20},{"authors":5,"custom_excerpt":13,"excerpt":13,"feature_image":14,"featured":15,"id":16,"meta_description":13,"meta_title":17,"og_description":8,"og_image":8,"og_title":8,"primary_author":18,"primary_tag":19,"published_at":22,"reading_time":23,"slug":24,"status":25,"tags":26,"title":17,"twitter_description":8,"twitter_image":8,"twitter_title":31,"updated_at":32,"visibility":21,"lexical":33},[6],{"bio":7,"facebook":8,"instagram":8,"linkedin":8,"location":9,"name":10,"profile_image":11,"slug":12,"tiktok":8,"twitter":8,"website":8,"youtube":8},"A Columnist at Rola IP, Chloe is deeply curious about digital marketing and search engine logic. Outside of work, she enjoys experimenting with web layout tools, photography, and image processing.",null,"Chloe是Rola IP的专栏作者。生活中，她对数字营销和搜索引擎背后的逻辑充满好奇。除了研究各种实用的网页排版工具，她还热爱摄影与图像处理。","Chloe Sun","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FPixPin_2026-08-13_11-09-19.png","chloe","Python web scraping JavaScript pages: find XHR data, use Playwright or Selenium, handle waits, validate output, and add proxies safely for dynamic sites.","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002F-------14.webp",false,"6a9aa17b4956c90001beef5b","Python Web Scraping JavaScript Pages: 3 Reliable Methods",{"bio":7,"facebook":8,"instagram":8,"linkedin":8,"location":9,"name":10,"profile_image":11,"slug":12,"tiktok":8,"twitter":8,"website":8,"youtube":8},{"description":8,"feature_image":8,"name":20,"slug":20,"visibility":21},"en","public","2026-09-04T10:53:24.000Z",8,"python-web-scraping-javascript","published",[27,28],{"description":8,"feature_image":8,"name":20,"slug":20,"visibility":21},{"description":8,"feature_image":8,"name":29,"slug":30,"visibility":21},"教程","guides","javascript scraping python","2026-10-10T06:16:38.000Z","{\"root\":{\"children\":[{\"type\":\"markdown\",\"version\":1,\"markdown\":\"## Quick Answer\\n\\nTo scrape JavaScript-rendered pages with Python, inspect initial HTML and Fetch\u002FXHR calls first. Request an authorized JSON endpoint when possible. If browser execution or interaction is required, use Playwright or Selenium and wait for a specific condition. Validate records before saving. Start with the included three-record fixture, then test one permitted target.\\n\\nThis guide is about using Python to scrape content produced by JavaScript. It is not a Python-versus-JavaScript language comparison.\\n\\n## Before You Scrape\\n\\nConfirm that you are authorized to automate the target, that its rules and authentication boundaries allow the workflow, and that you know which fields count as success. Also check whether an official API, export, feed, or licensed dataset already provides the data.\\n\\nA public URL does not answer every permission question. The Robots Exclusion Protocol lets owners publish crawler rules, but [RFC 9309](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9309) distinguishes those rules from access authorization. Treat permission, robots.txt, contractual terms, privacy, and applicable law as separate checks.\\n\\nThis tutorial uses a controlled local fixture. It returns three fictional product records from `\u002Fapi\u002Fproducts` after a 700 ms JavaScript delay. Each method sends one request, uses bounded timeouts, performs no retries, needs no login, and sends no traffic to a third-party target.\\n\\n## Why Requests and Beautiful Soup Return Empty Results\\n\\nA browser page has two relevant states: the initial HTTP response and the live DOM after scripts, API calls, and interactions run.\\n\\n[Requests](https:\u002F\u002Frequests.readthedocs.io\u002Fen\u002Flatest\u002F) downloads an HTTP response; it does not provide a browser JavaScript runtime. [Beautiful Soup](https:\u002F\u002Fwww.crummy.com\u002Fsoftware\u002FBeautifulSoup\u002Fbs4\u002Fdoc\u002F) parses supplied HTML or XML. It can parse rendered markup captured by another tool, but it does not create that rendered state.\\n\\nThe fixture makes the difference measurable. Requests and Beautiful Soup find zero `.product-card` elements in the initial HTML. After Chromium runs the script and the first card becomes visible, Playwright finds three.\\n\\n![requests-vs-rendered-evidence](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002F01-requests-vs-rendered-evidence.webp)\\n\\nAn empty selector is not automatic proof of JavaScript rendering. The selector may be wrong, or the response may be a consent page, authentication redirect, iframe shell, or access denial. Record the final URL, status, content type, title, and body sample before changing tools.\\n\\n## Find the Real Data Source First\\n\\nOpen View Source or save `response.text`, then search for one value visible in the browser. If it is absent from the response but present in DevTools Elements, JavaScript probably added it later.\\n\\nNext, open Chrome DevTools, select Network, reload the page, and reproduce the click or scroll that reveals the data. Inspect responses containing the required value. The official [Chrome DevTools Network guide](https:\u002F\u002Fdeveloper.chrome.com\u002Fdocs\u002Fdevtools\u002Fnetwork\u002F) documents response, initiator, timing, and filtering workflows.\\n\\nDo not copy every browser header. Reproduce only what an authorized endpoint requires. Never put a private token, session cookie, CSRF token, API key, or proxy credential in source code.\\n\\n| Method | Use it when | Advantage | Limitation |\\n|---|---|---|---|\\n| Requests + JSON endpoint | A documented or permitted endpoint exposes all fields | Fast and structured | Endpoint and authorization can change |\\n| Playwright | A new project needs execution or interaction | Modern locators, contexts, auto-waiting | Browser binaries and resource cost |\\n| Selenium | Existing WebDriver\u002FGrid infrastructure matters | Mature ecosystem and organizational fit | More explicit synchronization |\\n| Managed rendering | Browser infrastructure should be outsourced | Less local maintenance | Provider cost and less control |\\n\\nThe [Python web scraping library comparison](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fpython-web-scraping-libraries\u002F) explains why clients, parsers, crawlers, and browsers occupy different layers.\\n\\n## Reproduce the Controlled Test\\n\\nThe package contains the fixture, server, three scraper scripts, outputs, and images.\\n\\n```text\\npython-web-scraping-javascript-package\u002F\\n├── fixture\u002Findex.html\\n├── scripts\u002Ffixture_server.py\\n├── scripts\u002Frequests_probe.py\\n├── scripts\u002Fplaywright_scraper.py\\n├── scripts\u002Fselenium_scraper.py\\n├── requirements.txt\\n├── output\u002F\\n└── images\u002F\\n```\\n\\n### Tested environment\\n\\n| Component | Verified value |\\n|---|---|\\n| Operating system | Windows 11 |\\n| Python | 3.12.13 |\\n| Requests | 2.32.5 |\\n| Beautiful Soup | 4.14.3 |\\n| Playwright \u002F Chromium | 1.55.0 \u002F 140.0.7339.16 |\\n| Selenium \u002F Chrome | 4.35.0 \u002F 152.0.7977.64 |\\n| Last run | September 3, 2026 |\\n\\nPin deployed versions and rerun the fixture after package or browser upgrades.\\n\\n### Install and start the fixture\\n\\nWindows PowerShell:\\n\\n```powershell\\npython -m venv .venv\\n.\\\\.venv\\\\Scripts\\\\python.exe -m pip install -r requirements.txt\\n.\\\\.venv\\\\Scripts\\\\python.exe -m playwright install chromium\\n.\\\\.venv\\\\Scripts\\\\python.exe scripts\\\\fixture_server.py\\n```\\n\\nmacOS or Linux:\\n\\n```bash\\npython3 -m venv .venv\\nsource .venv\u002Fbin\u002Factivate\\npython -m pip install -r requirements.txt\\npython -m playwright install chromium\\npython scripts\u002Ffixture_server.py\\n```\\n\\nThe official [Playwright installation guide](https:\u002F\u002Fplaywright.dev\u002Fpython\u002Fdocs\u002Fintro) separates package installation from browser installation. Expected server output is `Fixture: http:\u002F\u002F127.0.0.1:8765\u002F`.\\n\\n## Method 1: Request the JSON Endpoint Directly\\n\\nRun the probe in a second terminal:\\n\\n```powershell\\n.\\\\.venv\\\\Scripts\\\\python.exe scripts\\\\requests_probe.py\\n```\\n\\nIts core logic checks both the initial page and the JSON endpoint:\\n\\n```python\\npage = requests.get(BASE_URL, timeout=(3, 10))\\npage.raise_for_status()\\ninitial_cards = BeautifulSoup(page.text, \\\"html.parser\\\").select(\\\".product-card\\\")\\n\\napi = requests.get(urljoin(BASE_URL, \\\"\u002Fapi\u002Fproducts\\\"), timeout=(3, 10))\\napi.raise_for_status()\\nrecords = [validate(item) for item in api.json()[\\\"results\\\"]]\\nassert len(records) == 3\\n```\\n\\nExpected output:\\n\\n```text\\nInitial HTML cards: 0\\nAPI records: 3\\nSaved: requests-products.json\\n```\\n\\nThis is preferable when the endpoint is stable, permitted, and complete. A request visible in DevTools is not automatically public or reusable; check its documented access model.\\n\\n## Method 2: Render with Playwright\\n\\nUse a browser when the data requires execution, clicks, scrolling, storage, or another browser state.\\n\\n```python\\nfrom playwright.sync_api import sync_playwright\\n\\nBASE_URL = \\\"http:\u002F\u002F127.0.0.1:8765\u002F\\\"\\n\\nwith sync_playwright() as p:\\n    browser = p.chromium.launch(headless=True)\\n    page = browser.new_page(viewport={\\\"width\\\": 1280, \\\"height\\\": 800})\\n    page.goto(BASE_URL, wait_until=\\\"domcontentloaded\\\", timeout=30_000)\\n\\n    cards = page.locator(\\\".product-card\\\")\\n    cards.first.wait_for(state=\\\"visible\\\", timeout=10_000)\\n    assert cards.count() == 3\\n\\n    records = []\\n    for card in cards.all():\\n        record = {\\n            \\\"id\\\": card.get_attribute(\\\"data-product-id\\\"),\\n            \\\"name\\\": card.locator(\\\"h2\\\").inner_text().strip(),\\n            \\\"raw_price\\\": card.locator(\\\".price\\\").inner_text().strip(),\\n        }\\n        if not all(record.values()):\\n            raise ValueError(f\\\"Invalid record: {record!r}\\\")\\n        records.append(record)\\n\\n    browser.close()\\n```\\n\\nRun `scripts\u002Fplaywright_scraper.py`. The verified output is:\\n\\n```text\\nRendered cards: 3\\nFirst record: p-101 | Atlas Keyboard | USD 89.00\\nSaved: playwright-products.json\\nScreenshot: 02-playwright-rendered-page.png\\n```\\n\\n![playwright-rendered-page](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002F02-playwright-rendered-page.webp)\\n\\n[Playwright auto-waiting](https:\u002F\u002Fplaywright.dev\u002Fpython\u002Fdocs\u002Factionability) covers actionability checks. Extraction still needs a condition tied to the data. The [Playwright Page API](https:\u002F\u002Fplaywright.dev\u002Fpython\u002Fdocs\u002Fapi\u002Fclass-page) labels `networkidle` discouraged for readiness assertions. Prefer a visible record, a known response, a count increase, a URL state, or schema validation.\\n\\n## Method 3: Use Selenium with Explicit Waits\\n\\nSelenium fits teams with WebDriver\u002FGrid or established browser tooling. The included script waits for visible cards, validates records, writes JSON, captures a screenshot, and closes the driver.\\n\\n```python\\nwait = WebDriverWait(driver, 10)\\ncards = wait.until(\\n    EC.visibility_of_all_elements_located((By.CSS_SELECTOR, \\\".product-card\\\"))\\n)\\n```\\n\\nRun:\\n\\n```powershell\\n.\\\\.venv\\\\Scripts\\\\python.exe scripts\\\\selenium_scraper.py\\n```\\n\\nThe verified run returned the same three records. Selenium's [waiting strategies](https:\u002F\u002Fwww.selenium.dev\u002Fdocumentation\u002Fwebdriver\u002Fwaits\u002F) describe explicit waits and warn against mixing implicit and explicit waits because timeout behavior can become unpredictable.\\n\\nFor a larger Selenium project with pagination, logs, and diagnostics, see [How to Use Selenium for Web Scraping](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fhow-to-use-selenium-for-web-scraping\u002F).\\n\\n## Handle Tables, Pagination, and Infinite Scroll\\n\\nA rendered first page is not proof of completeness. Watch Network while changing pages, sorting a table, clicking Load more, or scrolling. A permitted endpoint with a page, offset, or cursor is usually easier to validate.\\n\\nIf browser interaction is required, record the current item count, perform one action, and wait for the count or cursor to change. Cap the rounds and stop when no new records arrive. Never use an unbounded loop against a live site.\\n\\nMinimum output fields should include `source_url`, `record_id`, the raw value, normalized value, `retrieved_at`, method, region where relevant, status, and an evidence path. Treat zero rows, missing required fields, implausible counts, duplicates, or denial pages as failures.\\n\\n## Add a Proxy Only for a Measured Requirement\\n\\nA browser executes JavaScript. A proxy changes the network route, exit region, and session behavior.\\n\\nRola IP's [Proxy Networks documentation](https:\u002F\u002Fdoc.rola-ip.co\u002Fguide\u002Fproxy-networks\u002F) lists rotating residential, rotating datacenter, and mobile networks. All support country parameters; rotating residential also supports state and city. The page also documents credential and API-whitelist access, 1–120 minute session time, and `-f-1` per-request rotation.\\n\\n![rola-ip-proxy-networks-docs](https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002F04-rola-ip-proxy-networks-docs.webp)\\n\\nUse no proxy when direct access already returns the correct authorized content. Consider rotating residential for independent regional checks that genuinely need residential or state\u002Fcity routing. Consider rotating datacenter for low-risk, country-level, stateless, cost-sensitive collection. Keep one sticky session for an authorized multistep flow. Mobile IP should be limited to mobile-carrier-specific requirements.\\n\\nThe packaged `scripts\u002Frola_playwright_proxy.py` is syntax-checked but not live-tested because no account credentials were available. It reads values from environment variables:\\n\\n```python\\nproxy = {\\n    \\\"server\\\": required(\\\"ROLA_PROXY_SERVER\\\"),\\n    \\\"username\\\": required(\\\"ROLA_PROXY_USERNAME\\\"),\\n    \\\"password\\\": required(\\\"ROLA_PROXY_PASSWORD\\\"),\\n}\\nbrowser = p.chromium.launch(headless=True, proxy=proxy)\\n```\\n\\nGenerate exact connection values in the current dashboard. Environment variables reduce source-code exposure but are not a secret vault; use an approved secret manager in production and clear temporary credentials after testing.\\n\\nIf the gateway uses `http:\u002F\u002F`, do not call the client-to-proxy authentication hop TLS-protected unless Rola IP confirms TLS for that gateway. Target HTTPS and first-hop protection are separate questions.\\n\\nUse the [residential proxy setup guide](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fhow-to-set-up-a-residential-proxy\u002F) for configuration. If you receive 403, 429, CAPTCHA, or a denial page, stop and diagnose instead of escalating evasion; the [scraping block troubleshooting guide](https:\u002F\u002Frola-ip.co\u002Fblog\u002Fhow-to-avoid-getting-blocked-while-scraping\u002F) covers classification, rate control, and caching.\\n\\n## Verify Three URLs Before Scaling\\n\\nChoose three authorized URLs: one expected success, one delayed\u002Finteractive page, and one empty or regional edge case. Run them directly first. Record valid-record rate, P50\u002FP95 latency, retries, browser time, and bytes.\\n\\nAdd a proxy only if the direct test proves a region or session need. Verify the exit separately, rerun the same URLs, and compare cost per usable record. The [Rola IP Proxy Checker](https:\u002F\u002Frola-ip.co\u002Ftools\u002Fproxy-checker\u002F) can support a controlled connectivity check. Do not expose long-lived credentials in screenshots, logs, tickets, or shared files.\\n\\nTrack fixture downloads, Playwright copies, Selenium copies, proxy-tool clicks, documentation clicks, and registrations as separate analytics events. Report direct and assisted conversions separately.\\n\\n## Common Errors and Fixes\\n\\n| Symptom | Verify | Fix |\\n|---|---|---|\\n| HTTP 200, zero records | Body, final URL, title, content type | Inspect JSON\u002FXHR; otherwise render and wait |\\n| Locator timeout | Screenshot, HTML, frames, failed requests | Correct state\u002Fselector; do not only increase timeout |\\n| Only first batch | Count and requests after interaction | Request next cursor or use a bounded loop |\\n| Headless differs | Viewport, cookies, locale, browser build | Reproduce settings and preserve evidence |\\n| 403\u002F429\u002FCAPTCHA | Response class and retry count | Stop\u002Fback off, review rules, cache, or use licensed route |\\n| Wrong region | Exit, cookie, language, timezone, page values | Align context and verify content |\\n| Memory grows | Open pages, contexts, drivers | Close resources in `finally` |\\n\\n## Production Checklist\\n\\n- Prefer an official API or export.\\n- Keep an authorized fixture in CI.\\n- Pin package and browser versions.\\n- Set connect, read, navigation, and element timeouts.\\n- Separate navigation, extraction, validation, denial, and routing errors.\\n- Use bounded retries with backoff.\\n- Throttle per host and cache to the freshness requirement.\\n- Preserve raw values before normalization.\\n- Save permitted failure evidence and redact secrets\u002Fpersonal data.\\n- Keep credentials out of source, logs, screenshots, and outputs.\\n- Measure valid records, latency, retries, browser minutes, and bandwidth.\\n- Recheck official documentation and target rules before scaling.\\n\\n## Conclusion\\n\\nFor Python web scraping of JavaScript pages, inspect the initial response, embedded state, and permitted Fetch\u002FXHR calls before using a browser. Choose Playwright for a new browser workflow or Selenium when WebDriver infrastructure makes it the better fit. Wait for measurable state and validate records in either case.\\n\\nThe controlled test produced zero cards in initial HTML and three validated records through direct JSON, Playwright, and Selenium on September 3, 2026. Add Rola IP only after a direct pilot establishes a legitimate region or session requirement.\"},{\"children\":[],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"paragraph\",\"version\":1}],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}",{"items":35,"inline":15},[36,39,42,45,48,51,54,57],{"title":37,"desc":38},"Can Python scrape JavaScript-rendered websites?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Yes. Python can control a browser through Playwright or Selenium, or it can request the authorized JSON endpoint that a page uses to load its data. Start by comparing the initial response with the rendered DOM and inspecting Fetch\u002FXHR traffic. If a permitted endpoint returns every required field, Requests is usually simpler. If data appears only after browser execution or interaction, render the page and wait for a specific locator, response, or count change before extracting records.\u003C\u002Fspan>\u003C\u002Fp>",{"title":40,"desc":41},"Why does Beautiful Soup return an empty list when the browser shows data?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Beautiful Soup parses the HTML you give it; it does not execute the page's JavaScript. A server may return an HTML shell with empty containers, then the browser fetches JSON and inserts the visible records. Save the initial response and search for a known value. If it is absent, inspect embedded application data and Network responses. Also rule out a wrong selector, iframe, consent screen, authentication redirect, or denial page before assuming that JavaScript rendering is the only cause.\u003C\u002Fspan>\u003C\u002Fp>",{"title":43,"desc":44},"Should I use Playwright or Selenium for JavaScript web scraping?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Playwright is a strong default for a new Python browser project because it offers browser contexts, modern locators, network controls, and action auto-waiting. Selenium remains a sound choice when your organization already uses WebDriver, Selenium Grid, established test infrastructure, or a browser configuration that must be preserved. Neither is automatically faster or more reliable on every target. Test the same authorized pages with the same timeouts, waits, concurrency, and validation rules before standardizing on one.\u003C\u002Fspan>\u003C\u002Fp>",{"title":46,"desc":47},"Is networkidle enough to know that a JavaScript page is ready?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">No. A page can keep WebSocket or analytics connections open, become briefly idle before rendering finishes, or update after the idle window. Playwright's current Page API marks \u003C\u002Fspan>\u003Ccode spellcheck=\"false\" style=\"white-space: pre-wrap;\">\u003Cspan>networkidle\u003C\u002Fspan>\u003C\u002Fcode>\u003Cspan style=\"white-space: pre-wrap;\"> as discouraged for readiness assertions. Wait for evidence connected to the data you need: a record locator becomes visible, a particular response completes, the row count increases, or required fields pass validation. Always use a bounded timeout and save a screenshot plus HTML when the condition is not reached.\u003C\u002Fspan>\u003C\u002Fp>",{"title":49,"desc":50},"How do I scrape infinite scroll or a JavaScript table with Python?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">First inspect Fetch\u002FXHR requests while changing pages, sorting the table, clicking Load more, or scrolling. A permitted endpoint with a page number, offset, or cursor is usually easier to validate than browser interactions. If a browser is required, record the current item count, perform one action, and wait for the count or cursor to change. Set a maximum number of rounds and stop when no new records arrive. Deduplicate by a stable record ID or canonical URL before saving.\u003C\u002Fspan>\u003C\u002Fp>",{"title":52,"desc":53},"Can a proxy render JavaScript for a Python scraper?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">No. A proxy routes traffic through another network exit; it does not execute page scripts, create a rendered DOM, repair selectors, or validate data. Playwright, Selenium, or a rendering service performs the browser work. A proxy may be relevant after the scraper works when an authorized use case requires a regional exit, separate worker sessions, or temporary session continuity. Verify proxy connectivity and target content separately so that routing errors are not confused with rendering or extraction errors.\u003C\u002Fspan>\u003C\u002Fp>",{"title":55,"desc":56},"When should I use rotating or sticky proxy sessions?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Use rotating sessions for independent requests when each page can be processed without shared cookies or a continuous network identity. Use a sticky session for an authorized multistep flow such as a sequence of pages, redirects, or interactions that must retain the same exit temporarily. Do not rotate between login and subsequent stateful actions. Record the expected region and session policy with each run, then verify the content returned by the target rather than assuming an IP-database location guarantees the page variant.\u003C\u002Fspan>\u003C\u002Fp>",{"title":58,"desc":59},"What should I do after a 403, 429, or CAPTCHA response?","\u003Cp dir=\"ltr\">\u003Cspan style=\"white-space: pre-wrap;\">Classify and preserve the failure without storing secrets or personal data. Record the status, final URL, title, retry count, timestamp, and an allowed screenshot or HTML sample. Stop automatic retries, review authorization and target rules, reduce request rate, cache repeated results, and use an official API or licensed source when available. A proxy is not permission to bypass an access control, and changing IPs does not fix a broken selector, expired session, missing authentication, or prohibited workflow.\u003C\u002Fspan>\u003C\u002Fp>",{"@context":61,"@type":62,"@id":63,"mainEntity":64},"https:\u002F\u002Fschema.org","FAQPage","https:\u002F\u002Frola-ip.co\u002Fblog\u002Fpython-web-scraping-javascript\u002F#faq",[65,70,73,76,79,82,85,88],{"@type":66,"name":37,"acceptedAnswer":67},"Question",{"@type":68,"text":69},"Answer","Yes. Python can control a browser through Playwright or Selenium, or it can request the authorized JSON endpoint that a page uses to load its data. Start by comparing the initial response with the rendered DOM and inspecting Fetch\u002FXHR traffic. If a permitted endpoint returns every required field, Requests is usually simpler. If data appears only after browser execution or interaction, render the page and wait for a specific locator, response, or count change before extracting records.",{"@type":66,"name":40,"acceptedAnswer":71},{"@type":68,"text":72},"Beautiful Soup parses the HTML you give it; it does not execute the page's JavaScript. A server may return an HTML shell with empty containers, then the browser fetches JSON and inserts the visible records. Save the initial response and search for a known value. If it is absent, inspect embedded application data and Network responses. Also rule out a wrong selector, iframe, consent screen, authentication redirect, or denial page before assuming that JavaScript rendering is the only cause.",{"@type":66,"name":43,"acceptedAnswer":74},{"@type":68,"text":75},"Playwright is a strong default for a new Python browser project because it offers browser contexts, modern locators, network controls, and action auto-waiting. Selenium remains a sound choice when your organization already uses WebDriver, Selenium Grid, established test infrastructure, or a browser configuration that must be preserved. Neither is automatically faster or more reliable on every target. Test the same authorized pages with the same timeouts, waits, concurrency, and validation rules before standardizing on one.",{"@type":66,"name":46,"acceptedAnswer":77},{"@type":68,"text":78},"No. A page can keep WebSocket or analytics connections open, become briefly idle before rendering finishes, or update after the idle window. Playwright's current Page API marks networkidle as discouraged for readiness assertions. Wait for evidence connected to the data you need: a record locator becomes visible, a particular response completes, the row count increases, or required fields pass validation. Always use a bounded timeout and save a screenshot plus HTML when the condition is not reached.",{"@type":66,"name":49,"acceptedAnswer":80},{"@type":68,"text":81},"First inspect Fetch\u002FXHR requests while changing pages, sorting the table, clicking Load more, or scrolling. A permitted endpoint with a page number, offset, or cursor is usually easier to validate than browser interactions. If a browser is required, record the current item count, perform one action, and wait for the count or cursor to change. Set a maximum number of rounds and stop when no new records arrive. Deduplicate by a stable record ID or canonical URL before saving.",{"@type":66,"name":52,"acceptedAnswer":83},{"@type":68,"text":84},"No. A proxy routes traffic through another network exit; it does not execute page scripts, create a rendered DOM, repair selectors, or validate data. Playwright, Selenium, or a rendering service performs the browser work. A proxy may be relevant after the scraper works when an authorized use case requires a regional exit, separate worker sessions, or temporary session continuity. Verify proxy connectivity and target content separately so that routing errors are not confused with rendering or extraction errors.",{"@type":66,"name":55,"acceptedAnswer":86},{"@type":68,"text":87},"Use rotating sessions for independent requests when each page can be processed without shared cookies or a continuous network identity. Use a sticky session for an authorized multistep flow such as a sequence of pages, redirects, or interactions that must retain the same exit temporarily. Do not rotate between login and subsequent stateful actions. Record the expected region and session policy with each run, then verify the content returned by the target rather than assuming an IP-database location guarantees the page variant.",{"@type":66,"name":58,"acceptedAnswer":89},{"@type":68,"text":90},"Classify and preserve the failure without storing secrets or personal data. Record the status, final URL, title, retry count, timestamp, and an allowed screenshot or HTML sample. Stop automatic retries, review authorization and target rules, reduce request rate, cache repeated results, and use an official API or licensed source when available. A proxy is not permission to bypass an access control, and changing IPs does not fix a broken selector, expired session, missing authentication, or prohibited workflow.","{\"@context\":\"https:\u002F\u002Fschema.org\",\"@type\":\"FAQPage\",\"@id\":\"https:\u002F\u002Frola-ip.co\u002Fblog\u002Fpython-web-scraping-javascript\u002F#faq\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"Can Python scrape JavaScript-rendered websites?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. Python can control a browser through Playwright or Selenium, or it can request the authorized JSON endpoint that a page uses to load its data. Start by comparing the initial response with the rendered DOM and inspecting Fetch\u002FXHR traffic. If a permitted endpoint returns every required field, Requests is usually simpler. If data appears only after browser execution or interaction, render the page and wait for a specific locator, response, or count change before extracting records.\"}},{\"@type\":\"Question\",\"name\":\"Why does Beautiful Soup return an empty list when the browser shows data?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Beautiful Soup parses the HTML you give it; it does not execute the page's JavaScript. A server may return an HTML shell with empty containers, then the browser fetches JSON and inserts the visible records. Save the initial response and search for a known value. If it is absent, inspect embedded application data and Network responses. Also rule out a wrong selector, iframe, consent screen, authentication redirect, or denial page before assuming that JavaScript rendering is the only cause.\"}},{\"@type\":\"Question\",\"name\":\"Should I use Playwright or Selenium for JavaScript web scraping?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Playwright is a strong default for a new Python browser project because it offers browser contexts, modern locators, network controls, and action auto-waiting. Selenium remains a sound choice when your organization already uses WebDriver, Selenium Grid, established test infrastructure, or a browser configuration that must be preserved. Neither is automatically faster or more reliable on every target. Test the same authorized pages with the same timeouts, waits, concurrency, and validation rules before standardizing on one.\"}},{\"@type\":\"Question\",\"name\":\"Is networkidle enough to know that a JavaScript page is ready?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. A page can keep WebSocket or analytics connections open, become briefly idle before rendering finishes, or update after the idle window. Playwright's current Page API marks networkidle as discouraged for readiness assertions. Wait for evidence connected to the data you need: a record locator becomes visible, a particular response completes, the row count increases, or required fields pass validation. Always use a bounded timeout and save a screenshot plus HTML when the condition is not reached.\"}},{\"@type\":\"Question\",\"name\":\"How do I scrape infinite scroll or a JavaScript table with Python?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"First inspect Fetch\u002FXHR requests while changing pages, sorting the table, clicking Load more, or scrolling. A permitted endpoint with a page number, offset, or cursor is usually easier to validate than browser interactions. If a browser is required, record the current item count, perform one action, and wait for the count or cursor to change. Set a maximum number of rounds and stop when no new records arrive. Deduplicate by a stable record ID or canonical URL before saving.\"}},{\"@type\":\"Question\",\"name\":\"Can a proxy render JavaScript for a Python scraper?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. A proxy routes traffic through another network exit; it does not execute page scripts, create a rendered DOM, repair selectors, or validate data. Playwright, Selenium, or a rendering service performs the browser work. A proxy may be relevant after the scraper works when an authorized use case requires a regional exit, separate worker sessions, or temporary session continuity. Verify proxy connectivity and target content separately so that routing errors are not confused with rendering or extraction errors.\"}},{\"@type\":\"Question\",\"name\":\"When should I use rotating or sticky proxy sessions?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Use rotating sessions for independent requests when each page can be processed without shared cookies or a continuous network identity. Use a sticky session for an authorized multistep flow such as a sequence of pages, redirects, or interactions that must retain the same exit temporarily. Do not rotate between login and subsequent stateful actions. Record the expected region and session policy with each run, then verify the content returned by the target rather than assuming an IP-database location guarantees the page variant.\"}},{\"@type\":\"Question\",\"name\":\"What should I do after a 403, 429, or CAPTCHA response?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Classify and preserve the failure without storing secrets or personal data. Record the status, final URL, title, retry count, timestamp, and an allowed screenshot or HTML sample. Stop automatic retries, review authorization and target rules, reduce request rate, cache repeated results, and use an official API or licensed source when available. A proxy is not permission to bypass an access control, and changing IPs does not fix a broken selector, expired session, missing authentication, or prohibited workflow.\"}}]}",[93],"\u002Fblog\u002Fpython-web-scraping-javascript\u002F",{"prev":95,"next":108,"related":119,"popular":153,"latest":219},{"id":96,"title":97,"slug":98,"feature_image":99,"published_at":100,"twitter_title":101,"primary_tag":102,"tags":103},"6a9e75054956c90001beef94","Best SEO Proxies Providers 2026: Complete Guide to SEO Rank Tracking and SERP Collection","best-seo-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002Fbest-seo-proxies-article-cover-image.webp","2026-09-07T08:30:14.000Z","seo proxy",{"name":20,"slug":20},[104,105],{"name":20,"slug":20,"visibility":21},{"name":106,"slug":107,"visibility":21},"排行榜","top-picks",{"id":109,"title":110,"slug":111,"feature_image":112,"published_at":113,"twitter_title":114,"primary_tag":115,"tags":116},"6a9a9bd24956c90001beef26","How to Scrape Images From a Website With Python","how-to-scrape-images-from-website-python","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002F-------13.webp","2026-09-04T10:31:26.000Z","how to scrape images from website python",{"name":20,"slug":20},[117,118],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},[120,131,142],{"id":121,"title":122,"slug":123,"feature_image":124,"published_at":125,"twitter_title":126,"primary_tag":127,"tags":128},"6b0d3e4b92ab700001dc0a73","Scrape Indeed Jobs with Python: Extract Job Fields and Export to CSV","scrape-indeed-jobs","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FScrape-Indeed-Jobs.webp","2026-11-30T09:37:05.000Z","indeed job scraper",{"name":20,"slug":20},[129,130],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":132,"title":133,"slug":134,"feature_image":135,"published_at":136,"twitter_title":137,"primary_tag":138,"tags":139},"6b0d2bcb92ab700001dc0a12","Node.js HTTP Proxy Tutorial: Send HTTPS Requests with Rola IP and Verify the Exit IP","node-js-http-proxy","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FNode.js-HTTP-Proxy-Tutorial_-Send-HTTPS-Requests-with-Rola-IP-and-Verify-the-Exit-IP.webp","2026-11-30T07:58:57.000Z","node js http proxy",{"name":20,"slug":20},[140,141],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":143,"title":144,"slug":145,"feature_image":146,"published_at":147,"twitter_title":148,"primary_tag":149,"tags":150},"6b09485d92ab700001dc0953","How to Set Up Chrome DevTools MCP for Multi-Region Geo-Testing with Residential Proxies","chrome-devtools-mcp-proxy-setup","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002Fchrome-devtools-mcp-proxy-setup.webp","2026-11-27T09:22:44.000Z","chrome-devtools-mcp proxy setup",{"name":20,"slug":20},[151,152],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},[154,169,181,193,205],{"id":155,"title":156,"slug":157,"feature_image":158,"published_at":159,"twitter_title":160,"primary_tag":161,"tags":162},"6aa1292f4956c90001bef44e","ProxySite.com Review (2026): Is It Safe? 5 Best Alternatives","proxysite-review-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002FProxySite-Review-and--Alternatives-article-cover-image.webp","2026-09-09T10:16:50.000Z","proxysite",{"name":20,"slug":20},[163,164,167],{"name":20,"slug":20,"visibility":21},{"name":165,"slug":166,"visibility":21},"对比选型","comparisons",{"name":168,"slug":168,"visibility":21},"hot",{"id":170,"title":171,"slug":172,"feature_image":173,"published_at":174,"twitter_title":175,"primary_tag":176,"tags":177},"6a978f9a4956c90001bee8bb","BlockAway Alternatives: 6 Best Options (2026)","blockaway-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F09\u002FBlockAway-Alternatives-article-cover-image.webp","2026-09-02T03:14:08.000Z","blockaway alternative",{"name":20,"slug":20},[178,179,180],{"name":20,"slug":20,"visibility":21},{"name":165,"slug":166,"visibility":21},{"name":168,"slug":168,"visibility":21},{"id":182,"title":183,"slug":184,"feature_image":185,"published_at":186,"twitter_title":187,"primary_tag":188,"tags":189},"6a912ce84956c90001bee35d","HTTPX vs Requests vs aiohttp: Features, Performance, and Python Use Cases","httpx-vs-requests-vs-aiohttp","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FHTTPX-vs-Requests-vs-aiohttp-article-cover-image.webp","2026-08-28T07:27:34.000Z","httpx vs requests",{"name":20,"slug":20},[190,191,192],{"name":20,"slug":20,"visibility":21},{"name":165,"slug":166,"visibility":21},{"name":168,"slug":168,"visibility":21},{"id":194,"title":195,"slug":196,"feature_image":197,"published_at":198,"twitter_title":199,"primary_tag":200,"tags":201},"6a90fcea4956c90001bee256","8 Best Germany Proxies in 2026: Provider Comparison","best-germany-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002FBest-Germany-Proxies-article-cover-image.webp","2026-08-28T03:40:55.000Z","germany proxy",{"name":20,"slug":20},[202,203,204],{"name":20,"slug":20,"visibility":21},{"name":165,"slug":166,"visibility":21},{"name":168,"slug":168,"visibility":21},{"id":206,"title":207,"slug":208,"feature_image":209,"published_at":210,"twitter_title":211,"primary_tag":212,"tags":213},"6a8e92664956c90001beddc2","Bing Rank Tracker: Reliable Local SERP Monitoring Guide","bing-rank-tracker","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F08\u002F-------16.webp","2026-08-26T07:42:04.000Z","bing rank checker",{"name":20,"slug":20},[214,215,218],{"name":20,"slug":20,"visibility":21},{"name":216,"slug":217,"visibility":21},"应用场景","use-cases",{"name":168,"slug":168,"visibility":21},[220,231,242,253,264],{"id":221,"title":222,"slug":223,"feature_image":224,"published_at":225,"twitter_title":226,"primary_tag":227,"tags":228},"6b0946f492ab700001dc0920","Best Rotating Proxies in 2026 7 Rotating Proxy Providers Compared","best-rotating-proxies","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FBest-Rotating-Proxies-in-2026-7-Rotating-Proxy-Providers-Compared.webp","2026-11-27T09:07:09.000Z","best rotating proxies",{"name":20,"slug":20},[229,230],{"name":20,"slug":20,"visibility":21},{"name":106,"slug":107,"visibility":21},{"id":232,"title":233,"slug":234,"feature_image":235,"published_at":236,"twitter_title":237,"primary_tag":238,"tags":239},"6b07a50492ab700001dc0603","How to Configure an NGINX Docker Reverse Proxy with Rola IP Egress","nginx-docker-reverse-proxy","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FHow-to-Configure-an-NGINX-Docker-Reverse-Proxy-with-Rola-IP-Egress-1.webp","2026-11-26T03:21:51.000Z","nginx docker reverse proxy",{"name":20,"slug":20},[240,241],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":243,"title":244,"slug":245,"feature_image":246,"published_at":247,"twitter_title":248,"primary_tag":249,"tags":250},"6b079b8692ab700001dc05ce","Android Proxy Settings for Mobile Network: The No-Root Guide (2026)","android-proxy-settings-mobile-network","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FAndroid-Proxy-Settings-for-Mobile-Network_-The-No-Root-Guide--2026-.webp","2026-11-26T03:10:40.000Z","android proxy settings mobile network",{"name":20,"slug":20},[251,252],{"name":20,"slug":20,"visibility":21},{"name":29,"slug":30,"visibility":21},{"id":254,"title":255,"slug":256,"feature_image":257,"published_at":258,"twitter_title":259,"primary_tag":260,"tags":261},"6b0655a092ab700001dc0440","Rammerhead Proxy: Setup, HTTP Upstreams and Alternatives","rammerhead-alternatives","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002Frammerhead-alternatives.webp","2026-11-25T03:59:48.000Z","Rammerhead Proxy",{"name":20,"slug":20},[262,263],{"name":20,"slug":20,"visibility":21},{"name":165,"slug":166,"visibility":21},{"id":265,"title":266,"slug":267,"feature_image":268,"published_at":269,"twitter_title":270,"primary_tag":271,"tags":272},"6b05417f92ab700001dc034d","ProxyEmpire Review (2026): Our Best Alternative for Predictable Bulk Residential Use","proxyempire-review","https:\u002F\u002Frola-ip.co\u002F__ghost__\u002Fcontent\u002Fimages\u002F2026\u002F11\u002FProxyEmpire-Review--2026-_-Our-Best-Alternative-for-Predictable-Bulk-Residential-Use.webp","2026-11-24T08:12:53.000Z","proxyempire review",{"name":20,"slug":20},[273,274],{"name":20,"slug":20,"visibility":21},{"name":165,"slug":166,"visibility":21}]