python+playwright 学习-75 playwright 通过浏览器发送post请求

前言

page.goto()可以通过浏览器直接发get请求, playwright也可以支持通过浏览器发送post请求。

page.goto()使用

page.goto() 访问网站的时候,实际上是有返回值的,可以获取到response 对象

from playwright.sync_api import sync_playwright, expect

# 上海悠悠 wx:283340479
# blog:https://www.cnblogs.com/yoyoketang/

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    context = browser.new_context()
    page = context.new_page()

    resp = page.goto('https://www.cnblogs.com/yoyoketang/')
    print(resp.status)    # 状态码
    print(resp.headers)   # 头部
    print(resp.body())    # 响应正文

playwright 发post请求

接下来发一个post请求

from playwright.sync_api import sync_playwright, expect

with sync_playwright() as p:
    browser = p.chromi

你可能感兴趣的:(playwright,python,学习,开发语言)