I am trying to use an online IDE called repl.it and use the webbrowser module to open a webpage. This is the code I use:
from webbrowser import *
webbrowser.open('https://reddit.com')
But the function returns False as indicated in the online console.
Does this possibly have to do with the fact that the program runs in a remote server? If so, does repl.it have a hook between the server and the client to be able to perform web browser manipulations?
Yev from Repl.it here, that would be returning false because webbrowser probably needs a browser to execute and, additionally, repl.it runs code on headless machines, meaning there is no gui to run browsers in
Related
I am trying to create a python application while using eel to create a user interface in html. My operating system is Ubuntu Linux and I'm using Firefox to display the web interface.
The problem I'm having is every time I run the python code, Firefox opens a blank page saying "Unable to connect" followed by "Firefox can't establish a connection to the server at localhost:8000". However, if I click the "Try Again" button once, twice, or three times, my interface is displayed.
Once open, I can navigate to different pages but I also noticed that once I navigate to a different page, some of my javascript stops working (specifically a window.close() function). I don't know if this is related but I thought I would mention it just in case.
Any advice on the matter would be greatly appreciated.
Thank you.
I changed my browser from firefox to chromium and now my interface loads on startup the first time. I know some documentation says it can be used with firefox, and it can, but it seems to be kind of buggy and works better with other browsers.
However, I'm still having trouble with my javascript not running but that will be another question.
I want to launch a TensorBoard server and a corresponding web page. I am using Windows and Python 3.9.
I have tried the following:
import subprocess
import webbrowser
subprocess.call(r'tensorboard --logdir=./runs')
webbrowser.open('http://localhost:6006', new=2, autoraise=True)
I thought the subprocess.call() is non-blocking, but it still blocks my Python code. I don't know if it is related to platforms. I need a non-blocking solution that can run on both Windows and Linux.
I want to know is there a way to create a webdriver by script1.py , but close the webdriver by script2.py . I don't use the time.sleep() because I set these scripts to execute after few month. And I'm afraid that the scripts will delay due to the network crash. Any ideas are welcome.
Thanks!
The Python Selenium framework, SeleniumBase, comes with a special pytest command-line option called, --reuse-session, which tells all your tests to reuse the same browser session, even if all the tests live in different Python files. (More info on SeleniumBase command-line options here.) When using --reuse-session mode, the first test run will spin up the web browser, and then the last test run will close it. This should give you what you're looking for, where a different Python script closes the browser than the one that originally opened it.
Background
I have built a chrome extension to run tasks automatically with python and selenium on my localhost.
I would like to use my extension on my smartphone (with a different network). For this, I just need to use a specific browser and its running well
The Problem
In order for my extension to work on a different device, I need a server to receive a request passing all the information to start the job.
The API is done, but I don't know how to proceed with the server part.
What I've Tried
I tried to host on Heroku, it's working and I can receive requests, but web-driver isn't working. To being headless and the server is located in Europe, the website is blocking my access to the content.
Also, I tried to use a proxy, but I need authentication, but that doesn't work with selenium.
Further Explanation
Basically, I need to enable my chrome extension to do a request directly to my personal computer or use a server with a graphical user interface to set-up the proxy manually, but I don't have any idea how to proceed with this or if that is even the best option.
Any thoughts about a good work around?
I am now developing a webpage crawler, unfortunately the website generates the results by ajax. Following some coders suggestion, I tried to use selenium, a test automation tool for python.
As the example given in the documentation:
driver = webdriver.Firefox()
This code executes to open the Firefox browser. And then do something just like filling the form, submitting and so on.
Frankly speaking, this example works well on my PC(ubuntu 12.10), but my project will finally transfer to a CentOS server.
What I am considering is whether the code(need to open a browser gui) can be successfully ran on the CentOS server over ssh because no KDE such as gnome provided on that machine.....
And if without browser gui, the code cannot work well, then is there any other solutions?
Any reply would be admired~
You can probably use the HtmlUnit driver if you enable javascript. The only way to be sure though is to test it out. Another option would be to try and run with an X framebuffer.