Context.route_from_har speichert sowohl als har-file als auch extrahiert ein Networking-LogPython

Python-Programme
Anonymous
 Context.route_from_har speichert sowohl als har-file als auch extrahiert ein Networking-Log

Post by Anonymous »

Ich versuche, den HAR-Log einer Sitzung mit Dramatikern mit
zu retten.

Code: Select all

context.route_from_har(har=path_har, update=True)
Ich möchte es nur als einzelne Har-Datei, aber es verschmutzt auch das Verzeichnis des Skripts mit Dateien wie JS-Sripts, HTML, CSS, Images, ... der Form 817ea1d1972ae248dc9abba87e8d2256f8959d.js>,

Code: Select all

from playwright.sync_api import sync_playwright

url = # some url
path_har = './session.har'

with sync_playwright() as p:
browser_args = (
...
)

browser = p.chromium.launch(
headless=False,
devtools=False, # only works when headless=False
ignore_default_args=browser_args
)

context = browser.new_context(
...
)

context.route_from_har(har=path_har, update=True)

page = context.new_page()
page.goto(url)

context.close() # close it to save har-file
browser.close()
< /code>
Überprüfen Sie den Verzeichnisinhalt < /p>
(venv)$ ls - 1
817ea1d1972ae248dc9eabba87e8d2256f84959d.js
85245ea78118d39e8d9d4bc1ab216228e5d66ce2.html
a4ec070813be6ef3584dc6c1fbe2bf411d2833bf.css
[...]
session.har
app.py

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post