chuanenlin commited on
Commit
e4cd2b5
1 Parent(s): 041ed15

Download PDF from URL

Browse files
Files changed (1) hide show
  1. utils.py +14 -0
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)