![]() |
|
How to see API call of websites in Chrome using Python? Alternatively, for a slightly more conversational to - Printable Version +- Proxy Community (https://proxycommunity.com/forum) +-- Forum: Use Case (https://proxycommunity.com/forum/forum-use-case) +--- Forum: Web Scraping (https://proxycommunity.com/forum/forum-web-scraping) +--- Thread: How to see API call of websites in Chrome using Python? Alternatively, for a slightly more conversational to (/thread-how-to-see-api-call-of-websites-in-chrome-using-python-alternatively-for-a-slightly-more-conversational-to) |
How to see API call of websites in Chrome using Python? Alternatively, for a slightly more conversational to - proxyByteX77 - 21-12-2024 Title: how to see api call of websites in chrome python Hey folks! So I’ve been trying to figure out *how to see api call of websites in chrome python* for a project. Like, when you inspect a site in Chrome DevTools, you can see the network tab with all the API calls, right? But I wanna automate that with Python—maybe log or save those calls. Anyone got a simple way to do this? I’ve heard of stuff like Selenium or Pyppeteer, but not sure if they’re overkill. Or maybe there’s a lighter lib I’m missing? Thanks in advance! 🙌 (PS: if you’ve got code snippets, even better!) “” - StealthCipher77 - 28-01-2025 Hey! For how to see api call of websites in chrome python, you can use Playwright—it’s like Selenium but faster and more modern. Here’s a quick snippet: ```python from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page() page.goto("https://example.com") requests = page.context.request.all() print(requests) ``` Works like a charm and captures all network activity. “” - maskedJump88 - 24-02-2025 If you're looking for a lightweight solution, check out requests-html. It’s not as powerful as Selenium but gets the job done for simple cases. Just load the page and inspect the network tab manually—sometimes the simplest way is the best! For how to see api call of websites in chrome python, you might not even need heavy automation. “” - deepDash99 - 12-03-2025 Pyppeteer is actually a great choice for this! It’s a Python port of Puppeteer, so it’s perfect for scraping API calls. Example: ```python import asyncio from pyppeteer import launch async def main(): browser = await launch() page = await browser.newPage() await page.goto('https://example.com') await page.waitFor(2000) # wait for calls print(await page.evaluate('window.performance.getEntries()')) asyncio.get_event_loop().run_until_complete(main()) ``` This logs all network requests, including API calls. “” - ghostDartX88 - 17-03-2025 Ever tried mitmproxy? It’s a man-in-the-middle proxy that logs ALL HTTP traffic, including API calls. Run it in a terminal, configure Chrome to use it as a proxy, and boom—you’ve got every request logged. For how to see api call of websites in chrome python, this is the nuclear option, but it works flawlessly. “” - InvisibleNode - 20-03-2025 Selenium isn’t overkill if you’re already familiar with it! Just enable HAR logging: ```python from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.set_capability('goog:loggingPrefs', {'performance': 'ALL'}) driver = webdriver.Chrome(options=options) driver.get("https://example.com") logs = driver.get_log('performance') print(logs) ``` This dumps all network activity, including API calls. “” - AnonWarrior22 - 21-03-2025 For a no-code solution, just use Chrome’s DevTools Protocol with pychrome. It’s a bit niche but super powerful for how to see api call of websites in chrome python. Setup is a hassle, but once it’s running, you can intercept every request. “” - maskedEscape77 - 23-03-2025 If you’re okay with a CLI tool, curl-impersonate can mimic browser requests and show you the API calls. Not pure Python, but sometimes the right tool isn’t in Python. Just a thought! “” - DarkXpertX - 23-03-2025 You could also use BeautifulSoup + requests and manually inspect the network tab first to see what endpoints are being called. Then, replicate those calls in Python. Not fully automated, but gets the job done for how to see api call of websites in chrome python. “” - stealthNodeX - 24-03-2025 Check out selenium-wire! It’s an extension of Selenium that lets you capture requests easily. ```python from seleniumwire import webdriver driver = webdriver.Chrome() driver.get('https://example.com') for request in driver.requests: if request.response: print(request.url, request.response.status_code) ``` Super simple and effective. |