Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create download_file.py

Abdul Wahab Junaidc6b4e57f0a92
diff --git a/Python Tools/Opening and reading URLs(urllib)/download_file.py b/Python Tools/Opening and reading URLs(urllib)/download_file.py
new file mode 100644
index 0000000..cc18383
--- /dev/null
+++ b/Python Tools/Opening and reading URLs(urllib)/download_file.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+import urllib.request
+
+print("starting download....")
+
+url="https://www.python.org/static/img/python-logo.png"
+
+#download file with urlretrieve
+urllib.request.urlretrieve(url, "python.png")
+
+#download file with urlopen
+with urllib.request.urlopen(url) as response:
+ print("Status:", response.status)
+ print( "Downloading python.png")
+ with open("python.png", "wb" ) as image:
+ image.write(response.read())