Skip to content

route.continue_(url=newurl) change request URL notwork  #569

@seobishop

Description

@seobishop
`# -*- codeing:utf8 -*-
from playwright.sync_api import sync_playwright


def baidu(route, request):
    newurl = request.url+"?direct"
    print('newurl:',newurl)
    route.continue_(url=newurl)


def run(playwright):
    chromium = playwright.chromium
    browser = chromium.launch(headless=False)
    page = browser.new_page()
    page.on("response", lambda response: print("Response: " + response.url))
    page.route("*robots*", baidu)
    page.goto("https://www.baidu.com/robots.txt") 


with sync_playwright() as playwright:
    run(playwright)
`

this code printed
newurl: http://www.baidu.com/robots.txt?direct Response: http://www.baidu.com/robots.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions