I built a web scraper with Selenium using Geckodriver for Linux64. The program clicks on a download link for an Excel file and downloads this file (automatically, without asking to save). This works fine on my 64-bit Ubuntu laptop.
My goal is to run this program on my Synology NAS server:
>uname -a
Linux name_of_nas 4.4.59+ #25556 SMP Thu Mar 4 17:52:53 CST 2021 aarch64 GNU/Linux synology_rtd1296_ds218play
The problem I encountered is that Geckodriver acts as a link between Selenium and the Firefox webbrowser. This would mean that I have to have the Firefox webbrowser installed on my NAS. I don't see how this can be achieved. The Geckodriver I installed on my NAS can be found here. This Geckodriver seems to be working, because the error I get when running my program is:
RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox
Other versions of the Geckodriver would give me the error:
OSError: [Errno 8] Exec format error: 'geckodriver'
Is there a way to download Firefox on my NAS to get this working? Or perhaps there is another way to achieve my goal?
Code of my test web scraper:
url = 'https://file-examples.com/index.php/sample-documents-download/sample-xls-download/'
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
options = Options()
options.add_argument('--headless')
profile = FirefoxProfile()
profile.set_preference("browser.download.dir", "/volume1/NAS storage/Jens/NAS_programs/qteam_scraper/data/")
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel")
cap = DesiredCapabilities().FIREFOX
cap["marionette"] = False
# Problem: geckodriver is a link between selenium and your firefox browser -> I need to have firefox installed on NAS server
driver = webdriver.Firefox(firefox_profile=profile, options=options, capabilities=cap) # Automatically uses geckodriver in /usr/local/bin/
driver.get(url)
driver.find_element_by_xpath('/html/body/div[1]/main/section/div/div[2]/div/div/table/tbody/tr[1]/td[5]/a[1]').click()
driver.quit()