File size: 953 Bytes
b8fdfd3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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.")