-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetcher.py
40 lines (32 loc) · 1.11 KB
/
fetcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import urllib.request
from fetcher_core import *
fcb()
def get_url():
fcc()
UNAME = input("ENTER UNAME: ")
PASS = input("ENTER PASS: ")
VALID_UNAME = "vinay"
VALID_PASS = "vinayj@123"
# Check username first
if UNAME != VALID_UNAME:
print("INVALID UNAME!, PROGRAM IS TERMINATED!!")
exit()
# Then check password
elif PASS != VALID_PASS:
print("INVALID PASS!, PROGRAM IS TERMINATED!!")
exit()
else:
URL = input("Enter Target URL (including http/https): ")
filename = input("Enter Filename (including file extension): ")
print("The Target URL is " + URL)
print("The Filename is " + filename)
try:
# Construct the full URL
full_url = URL if URL.endswith('/') else URL + '/'
full_url += filename
# Retrieve and save the file
urllib.request.urlretrieve(full_url, filename)
print(f"File saved as {filename}")
except Exception as e:
print(f"An error occurred: {e}")
get_url()