Spaces:
Running
Running
chuanenlin
commited on
Commit
·
e4cd2b5
1
Parent(s):
041ed15
Download PDF from URL
Browse files
utils.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import urllib.request
|
2 |
+
import os
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
def download_file(download_url):
|
6 |
+
response = urllib.request.urlopen(download_url)
|
7 |
+
filename = Path(download_url).name
|
8 |
+
file = open(filename, 'wb')
|
9 |
+
file.write(response.read())
|
10 |
+
file.close()
|
11 |
+
return filename
|
12 |
+
|
13 |
+
def remove_file(local_path):
|
14 |
+
os.remove(local_path)
|