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 repl.it

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

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

Is this what you mean?

import webbrowser
url = 'http://www.python.org/'

# 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.
webbrowser.open_new(url)
CaptainAnon (150)

The webdriver module opens the url requested in a browser window. The repl.it interface can't do that. Instead you could do this: https://repl.it/@CaptainAnon/Requests-Library-Demo

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 [repl.it]

CaptainAnon (150)

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