我正在尝试在 Google Colab 上安装 Firefox 并使用公共 URL 访问它的界面。
我的代码:
!apt-get update
!pip install pyngrok
!pip install selenium
!apt-get install firefox -y
from pyngrok import ngrok
import subprocess
# Launch the web browser
subprocess.Popen(['firefox', '--headless', '--no-sandbox', '--disable-dev-shm-usage', '--remote-debugging-port=8888'])
# Wait for Firefox to start
import time
time.sleep(5) # Adjust the delay if needed
# Create a public URL using ngrok
ngrok.set_auth_token('2Rds12n2TZQrrPo0SF7F4i7ZmGg_3qDDTjYdSAyH31y55mJuB')
browser_url = ngrok.connect(8888).public_url
# Display the public URL
print("Web Browser URL:", browser_url)
#Verification
!firefox --version
!lsof -i :8888
!netstat :8888
# Keep the cell running until interrupted
try:
while True:
pass
except KeyboardInterrupt:
print("Cell execution interrupted.")
finally:
# Stop ngrok
ngrok.kill()
错误:
在我的网络浏览器中打开公共 URL 后,它显示错误的请求。
你找到方法了吗?请让我知道我也在尝试做同样的事情。