Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from bs4 import BeautifulSoup
|
2 |
+
import requests
|
3 |
+
from zipfile import ZipFile
|
4 |
+
import os
|
5 |
+
|
6 |
+
# URL of the webpage
|
7 |
+
url = 'https://tabs.ultimate-guitar.com/tab/neko-case/hold-on-hold-on-chords-1237853'
|
8 |
+
|
9 |
+
# Send a request to the URL
|
10 |
+
response = requests.get(url)
|
11 |
+
html_content = response.text
|
12 |
+
|
13 |
+
# Parse HTML
|
14 |
+
soup = BeautifulSoup(html_content, 'html.parser')
|
15 |
+
|
16 |
+
# Find all image tags
|
17 |
+
image_tags = soup.find_all('img') # Modify this line based on actual HTML structure
|
18 |
+
|
19 |
+
# Directory to store images
|
20 |
+
os.makedirs('chord_images', exist_ok=True)
|
21 |
+
|
22 |
+
# Zip file to store images
|
23 |
+
with ZipFile('chord_images.zip', 'w') as zipf:
|
24 |
+
for i, img in enumerate(image_tags):
|
25 |
+
img_url = img['src'] # Assuming 'src' contains the image URL
|
26 |
+
img_data = requests.get(img_url).content
|
27 |
+
img_filename = f'chord_images/image_{i}.jpg'
|
28 |
+
with open(img_filename, 'wb') as f:
|
29 |
+
f.write(img_data)
|
30 |
+
zipf.write(img_filename)
|
31 |
+
|
32 |
+
print("Images saved and zipped.")
|