18 lines
377 B
Python
18 lines
377 B
Python
import tempfile
|
|
from pathlib import Path
|
|
|
|
import requests
|
|
|
|
|
|
def download(
|
|
url: str,
|
|
destination_folder: Path = Path(tempfile.gettempdir()),
|
|
file_name: str = "file.pdf",
|
|
) -> Path:
|
|
response = requests.get(url)
|
|
response.raise_for_status()
|
|
|
|
output_file = destination_folder / file_name
|
|
output_file.write_bytes(response.content)
|
|
|
|
return output_file
|