Skip to content

Commit 15acfc7

Browse files
authored
Scrap file and download from url
Scrap file and download from url write in binary format
1 parent 517e60c commit 15acfc7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

scrap_file.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Author : RIZWAN AHMAD
2+
3+
4+
5+
#pip3 install requests
6+
7+
import requests
8+
9+
10+
11+
#Function for download file parameter taking as url
12+
13+
def download(url):
14+
f = open('file_name.jpg','wb') # opening file in write binary('wb') mode with file_name.ext ext=extension
15+
f.write(requests.get(url).content) # Writing File Content in file_name.jpg
16+
f.close()
17+
print("Succesfully Downloaded")
18+
19+
url='https://avatars0.githubusercontent.com/u/29729380?s=400&v=4' #URL from which we want to download
20+
21+
download(url)
22+

0 commit comments

Comments
 (0)