Puppeteer - (Page.navigate: Cannot navigate to invalid URL)

Viewed 1426

here, I have an list of array My URL is from an array

URL:

url= result[urls]
console.log(url)

Output:

books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html

when I used this:

 await page.goto('"http://' + url + '"');

I got an error something like this:

 Error: Protocol error (Page.navigate): Cannot navigate to invalid URL

Note: When i used this instead:

await page.goto("http://books.toscrape.com/catalogue/soumission_998/index.html");

Then It Works

Anyone have idea about this?? How to solve this error :)

2 Answers

If SMTH answer didn't work. You could give await page.goto(`https://${url}`); a try.

I think that its your quotation marks

 await page.goto('"http://' + url + '"');

Should be

 await page.goto('http://' + url);
Related