cloudmaker
cloudmaker

Reputation: 39

playwright - some urls make page.goto hangup and set timeouts didn't resolved

The url in the code below (and some others that i'm finding) exists but the https server don't answer, so try to verify response.code >= 400 don't work. Set page timeouts also don't work. Problem is, i have to run a list of urls and when the script find one it hangup.

    url = 'https://mediafina.xyz'

    page.set_default_timeout = 120000
    page.set_default_navigation_timeout = 120000
    page.goto(url)

If i run showing the browser page on the screen

    browser = pw.chromium.launch({
        ...
        headless=False,
        ...
    }

The browser show in a minute or so:

Unable to access this site
mediafina.xyz has unexpectedly terminated the connection.

But i don't know how to get this event, if this is a playwright event. Google wasn't helpful.

What i'm missing or doing wrong ?

Upvotes: 0

Views: 2501

Answers (1)

cloudmaker
cloudmaker

Reputation: 39

I did the following:

def response_handler(response):
    if response.ok == False:
        page.close()

page.on("response", response_handler)

BEFORE page.goto(url) and now playwright don't hangup anymore.

Upvotes: 1

Related Questions