Ask coding questions

← Back to all posts
Why is the url not opening in python?
Haruto121 (11)

I tried this from stackoverflow but it isn't working at

I tried it here at but the url is not opening.

Answered by PYer (4015) [earned 5 cycles]
View Answer
PYer (4015)

Is this what you mean?

import webbrowser
url = ''

# Open URL in a new tab, if a browser window is already open.
webbrowser.open_new_tab(url + 'doc/')

# Open URL in new window, raising the window if possible.
CaptainAnon (150)

The webdriver module opens the url requested in a browser window. The interface can't do that. Instead you could do this:

Haruto121 (11)

@CaptainAnon Thanks but what if I want to open a site like say 'google' in the console what will I would have to do to achieve that...

CaptainAnon (150)

@Haruto121 Do you just want to display the code, or render the page (so it has a search bar, etc.)?

Haruto121 (11)

@CaptainAnon Yeah that's what i exactly want to get the search bar and all in console

ash15khng (723)

@Haruto121 I don't think that is very possible as of now in []

CaptainAnon (150)

@Haruto121 Are you trying to scrape the web with this?