Spaces:
Sleeping
Sleeping
from bs4 import BeautifulSoup | |
import requests | |
from zipfile import ZipFile | |
import os | |
# URL of the webpage | |
url = 'https://tabs.ultimate-guitar.com/tab/neko-case/hold-on-hold-on-chords-1237853' | |
# Send a request to the URL | |
response = requests.get(url) | |
html_content = response.text | |
# Parse HTML | |
soup = BeautifulSoup(html_content, 'html.parser') | |
# Find all image tags | |
image_tags = soup.find_all('img') # Modify this line based on actual HTML structure | |
# Directory to store images | |
os.makedirs('chord_images', exist_ok=True) | |
# Zip file to store images | |
with ZipFile('chord_images.zip', 'w') as zipf: | |
for i, img in enumerate(image_tags): | |
img_url = img['src'] # Assuming 'src' contains the image URL | |
img_data = requests.get(img_url).content | |
img_filename = f'chord_images/image_{i}.jpg' | |
with open(img_filename, 'wb') as f: | |
f.write(img_data) | |
zipf.write(img_filename) | |
print("Images saved and zipped.") | |