Webbrowser library on replit

Question:

I’m trying to write a program that opens webpages from python using the webbrowser library. Instead, it almost pretends the code doesn’t exist – it doesn’t execute. Any ideas?

**quick edit: it seems the library knows this as an issue, since the operating system might try to open it natively by accident. Considering replit is on a virtualized OS of sorts, it would make sense if this were the case. But if someone has a different workaround, that would be great!

import webbrowser
webbrowser.open_new_tab("file.html")

Idk if replit supports webbrowser library (since it’s a virtualized environment). The webbrowser library typically relies on the underlying operating system’s ability to handle URL requests and things like that.

Did you tried using requests or selenium as a workaround?

2 Likes

I have tried requests but it doesn’t seem to do what I am looking for unfortunately. Selenium looks like it would have the same problem as above, since it seems to open on the OS level, which, again is virtualized.

I wonder if this is more a bug, or not so much a bug but limitation, of replit, and not a code issue.

1 Like

Does the HTTP server approach is suitable for your situation?

Like you could create a simple HTTP server in Python (with Flask for example) and instead of trying to open a web browser, you would start this server.

1 Like

Very interesting idea. Though, again, I don’t think it will quite solve the problem. Maybe I should describe what I am trying to do:

I am trying to set up a system by which I can open SaaS apps from command line – think of it like a virtual cloud NAS of sorts. I want to be able to access my cloud storage apps into one accessible area.

I would just go ahead and make this in HTML, but there are some other things that I want to add that HTML would not be the best fit for. However, it seems that might be the best movement forward if I want to do that.

I think my best bet is to actually do some API work… Which I haven’t done before, but in order to do it, I would then need replit core (not the end of the world, though I think a little expensive) so as to ensure people don’t just have access to my stuff lol

2 Likes

Have you tried playwright?

1 Like

Considering your case I think it would be better just to make a GUI (you can use Tkinter or PyQt), that way you can create a graphical interface that can launch web pages and by that, you could create buttons or command inputs in your GUI that, when activated, launch a browser window or tab with the desired SaaS application.

Or you can just abadon Python and try playwright (node) as @Sky said

4 Likes

playwright is also Python as well.

Really? I always tought that playwright was only for node, good to know!

2 Likes

unfortunately, I think you’re right. I have not tried playwright yet, so I think that is my next best option lol

I’ll give it a shot and call this closed for now.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.