Fixes download_file() method not being able to store filename with question marks in Windows.
This commit is contained in:
parent
990701d9ee
commit
930763c198
|
@ -2,11 +2,13 @@
|
||||||
import codecs
|
import codecs
|
||||||
import fasteners
|
import fasteners
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from seleniumbase.fixtures import constants
|
from seleniumbase.fixtures import constants
|
||||||
from seleniumbase.fixtures import css_to_xpath
|
from seleniumbase.fixtures import css_to_xpath
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
|
||||||
def get_domain_url(url):
|
def get_domain_url(url):
|
||||||
|
@ -298,7 +300,11 @@ def _download_file_to(file_url, destination_folder, new_file_name=None):
|
||||||
if new_file_name:
|
if new_file_name:
|
||||||
file_name = new_file_name
|
file_name = new_file_name
|
||||||
else:
|
else:
|
||||||
file_name = file_url.split("/")[-1]
|
if platform.system() == "Windows":
|
||||||
|
url_parts = urlparse(file_url)
|
||||||
|
file_name = url_parts.path.split("/")[-1]
|
||||||
|
else:
|
||||||
|
file_name = file_url.split("/")[-1]
|
||||||
r = requests.get(file_url, timeout=5)
|
r = requests.get(file_url, timeout=5)
|
||||||
file_path = os.path.join(destination_folder, file_name)
|
file_path = os.path.join(destination_folder, file_name)
|
||||||
download_file_lock = fasteners.InterProcessLock(
|
download_file_lock = fasteners.InterProcessLock(
|
||||||
|
|
Loading…
Reference in New Issue