Script is working, saving Files to specific folder in current Directory

This commit is contained in:
2022-05-29 16:11:49 +02:00
parent 75e5b39caf
commit ae4970c16f
2 changed files with 27 additions and 11 deletions
+3
View File
@@ -120,6 +120,9 @@ venv.bak/
# mkdocs documentation
/site
/Driver
# mypy
.mypy_cache/
.dmypy.json
+24 -11
View File
@@ -1,24 +1,37 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.action_chains import ActionChains
import time
import os
curDir = os.path.abspath(os.getcwd())
folderName = "Downloads"
DownPath = os.path.join(curDir,folderName)
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", DownPath)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
s = Service("Driver\geckodriver.exe")
driver = webdriver.Firefox(firefox_profile=profile,service=s)
Link = "https://www.projekt-gutenberg.org/hugo/notreda1/notreda1.html"
DownloadURL = "http://www.epub2go.eu"
DownloadURL = "epub2go.eu"
driver.get(DownloadURL)
LinkField = driver.find_element_by_id("spiegelURL")
LinkField.send_keys(Link)
LinkField.send_keys(Keys.ENTER)
LinkField.submit()
DownloadButton =
driver.find_element_by_xpath("/html/body/div.wrapper/div#epub/div#ePubDLs/div#resultContainer0/a")
time.sleep(1)
DownloadButton.click()
Download = driver.find_element_by_xpath("/html/body/div/div[2]/div[1]/div/a")
Download.click()
driver = webdriver.Firefox()
driver.quit()
driver.close()