-
Notifications
You must be signed in to change notification settings - Fork 0
/
Certificate.py
94 lines (75 loc) · 2.77 KB
/
Certificate.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# from collections import deque
# def route_exists(from_row, from_column, to_row, to_column, map_matrix):
# rows = len(map_matrix)
# columns = len(map_matrix[0])
# # Check if input is invalid
# if (not (0 <= from_row < rows and 0 <= from_column < columns)) or (not (0 <= to_row < rows and 0 <= to_column < columns)):
# return False
# if not map_matrix[from_row][from_column] or not map_matrix[to_row][to_column]:
# return False
# directions = [(1,0),(-1,0),(0,-1),(0,1)]
# queue = deque([(from_row, from_column)])
# visited =set()
# visited.add((from_row, from_column))
# while queue:
# r, c = queue.popleft()
# if (r, c ) == (to_row, to_column):
# return True
# for dr, dc in directions:
# nr,nc = r+dr, r+dc
# if ((nr, nc) not in visited and map_matrix[nr][nc] and 0 <= nr < rows and 0 <= nc < columns):
# queue.append((nr, nc))
# visited.add((nr, nc))
# return False
# if __name__ == '__main__':
# map_matrix = [
# [True, False, False],
# [True, True, False],
# [False, True, True]
# ];
# print(route_exists(0, 0, 2, 2, map_matrix))
# # from datetime import datetime
# # def convert_to_date(date_string):
# # return datetime.strptime(date_string, "%Y/%m")
# # class Problem:
# # def convert_to_date(date_string):
# # return datetime.strptime(date_string, "%Y/%m")
# # def findMax(history):
# # # curr_date = datetime.now().date
# # count = 0
# # for i in range(len(history)):
# # date1 = convert_to_date(history[i][2])
# # date2 = convert_to_date(history[i][1])
# # diff = date1 - date2
# # if diff.days < 0:
# # continue
# # else:
# # count+=1
# # return count
# # history = [[1, "1997/01", "1007/01"], [2, "1998/03", "2009/04"], [3, "2005/04", "2005/05"]]
# # print(Problem.findMax(history))
from hashlib import sha1
def compute_hash(email):
return sha1(email.encode('utf-8')).hexdigest()
def compute_certificate_id(email):
email_clean = email.lower().strip()
return compute_hash(email_clean + '_')
cohort = 2024
course = 'mlops-zoomcamp'
your_id = compute_certificate_id('hmuai026@gmail.com')
url = f"https://certificate.datatalks.club/{course}/{cohort}/{your_id}.pdf"
print(url)
# Import libraries
import requests
from bs4 import BeautifulSoup
# URL from which pdfs to be downloaded
# Requests URL and get response object
response = requests.get(url)
# Check if request was successful
if response.status_code == 200:
# Save PDF to local folder
with open('./certificate.pdf', 'wb') as f:
f.write(response.content)
print('PDF saved successfully!')
else:
print('Failed to retrieve PDF.')