前言
每个Playwright浏览器上下文都有与其关联的APIRequestContext实例,该实例与浏览器上下文共享cookie存储,可以通过browser_context.request或page.request访问。也可以通过调用api_request.new_context()手动创建一个新的APIRequest上下文实例。
通过浏览器发请求
可以通过browser_context.request或page.request发送接口请求,该实例与浏览器上下文共享cookie存储。
from playwright.sync_api import sync_playwright, expect
# 上海悠悠 wx:283340479
# blog:https://www.cnblogs.com/yoyoketang/
REPO = "test-repo-1"
USER = "github-username"
API_TOKEN = "xx1122"
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
context =