-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_html.py
57 lines (51 loc) · 1.1 KB
/
generate_html.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
import pandas as pd
# Load the Excel file
df = pd.read_excel('mods.xlsx')
# Start the HTML file
html_content = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mods Grid</title>
<style>
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 10px;
}
.grid-item {
text-align: center;
padding: 10px;
border: 1px solid #ccc;
}
.grid-item img {
width: 100%;
height: auto;
}
</style>
</head>
<body>
<div class="grid-container">
'''
# Add each mod to the HTML file
for index, row in df.iterrows():
html_content += f'''
<div class="grid-item">
<a href="{row['mod_url']}" target="_blank">
<img src="{row['mod_image']}" alt="{row['mod_name']}">
<div>{row['mod_name']}</div>
</a>
</div>
'''
# End the HTML file
html_content += '''
</div>
</body>
</html>
'''
# Write the HTML file
with open('mods_grid.html', 'w') as f:
f.write(html_content)
print('HTML file generated successfully.')