Closed JimKarvo closed 3 weeks ago
Does this works:
from botasaurus.browser import browser, Driver
@browser(add_arguments=['--no-sandbox'])
def scrape_heading_task(driver: Driver, data):
# Visit the Omkar Cloud website
driver.get("https://www.omkar.cloud/")
# Retrieve the heading element's text
heading = driver.get_text("h1")
# Save the data as a JSON file in output/scrape_heading_task.json
return {
"heading": heading
}
# Initiate the web scraping task
scrape_heading_task()
Hello @Chetan11-dev Tryied on 2 different machines, but the same behaviur
File "/usr/local/lib/python3.11/dist-packages/botasaurus_driver/core/browser.py", line 51, in ensure_chrome_is_alive
raise Exception(f"Failed to connect to Chrome URL: {url}.")
Exception: Failed to connect to Chrome URL: http://127.0.0.1:44799/json/version.
Sollution found.
At ubuntu servers, we have to install virtual monitor
First, you need to install Xvfb
.
sudo apt-get update
sudo apt-get install xvfb
Start Xvfb on a specified display. For example, to start it on display :99, run:
Xvfb :99 -screen 0 1024x768x16 &
export DISPLAY=:99
Then the script works!
Also, if you run script like VM=true python main.py, it will then also work successfully
Hello,
I am trying to run ANY example code at linux (Ubuntu server), headless server.
The main problem that i am facing, is that I can't comunicate with browser.
The same code at windows pc works like a charm, maybe the botasaurus is not support linux servers?