0

Is it possible to get the information presented in e.g. http://localhost:9222/json directly from Puppeteer without having to make the http request?

Oldrich Svec
  • 4,191
  • 2
  • 28
  • 54

2 Answers2

0

I do not remember what information exactly in http://localhost:9222/json but you can use browser.version() for learn browser version and you can learn browser.wsEndpoint() for browser endpoint url, without http request.

0

Anyone know the answer to this? I have a similar question, my problem is that I want to know where the page.goto(url) resolves

I have a code like this:

url = "http://www.somewebsite.com/"
response = await page.goto(url, 
            waitUntil=['domcontentloaded', 'networkidle0'], timeout=30000
        )

Then I want to check when the url redirect, so I did it something like this

url_resolve = response.url

But the problem is I'm still getting the original url I requested, but checking http://localhost:9222/json, I'm getting something like this

[{
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/BA2493F44C89E9255BD0FE6B060AB0FE",
   "id": "BA2493F44C89E9255BD0FE6B060AB0FE",
   "title: "Some Website - Design",
   "type": "page",
   "url": "http://www.somewebsite.com/home/13112321/main.html"
   "webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/BA2493F44C89E9255BD0FE6B060AB0FE"
}]

So what I really want is to get the url I'm getting from the endpoint http://localhost:9222/json, which only accessable via http request not from puppeteer itself, btw I'm using pyppeteer

Update:

So I found a way to go around solving my use case, What I did was to use the evaluate method, by simply adding

current_url = await.page.evaluate('window.location.href', force_expr=True)

Then I'll get the current url of the open tab

Got the answer here

blufang
  • 51
  • 1
  • 4