Oldu hocam. Aynen aşağıdakileri uyguladım. Burayada yazalımda hem elimizin altında olsun. Hemde zorlanan arkadaşlar olursa benim gibi faydamız olsun.
sudo apt update
sudo apt install firefox python3-pip xvfb x11-utils --yes
sudo -H pip3 install bpython selenium
export DISPLAY=:2
Xvfb $DISPLAY -ac &
export GECKO_DRIVER_VERSION='v0.24.0'
wget https://github.com/mozilla/geckodriver/releases/download/$GECKO_DRIVER_VERSION/geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
tar -xvzf geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
rm geckodriver-$GECKO_DRIVER_VERSION-linux64.tar.gz
chmod +x geckodriver
sudo cp geckodriver /usr/local/bin/
cat <<EOF > script.py
#!/usr/bin/env python3
from selenium.webdriver import Firefox, FirefoxOptions, FirefoxProfile
ff_options = FirefoxOptions()
ff_options.headless = True
ff = Firefox(options=ff_options)
ff.quit()
EOF
chmod +x script.py
Kaynak:https://gist.github.com/pcgeek86/a1fd9d26f8ad46b51adf9513f67b95f2
cat < script.py bu kısımdan sonrasını yazmasınızda olur. Ben kendi kodumuda denedim hepsi çalıştı açıkcası.