|
from bs4 import BeautifulSoup |
|
import requests |
|
from zipfile import ZipFile |
|
import os |
|
|
|
|
|
url = 'https://tabs.ultimate-guitar.com/tab/neko-case/hold-on-hold-on-chords-1237853' |
|
|
|
|
|
response = requests.get(url) |
|
html_content = response.text |
|
|
|
|
|
soup = BeautifulSoup(html_content, 'html.parser') |
|
|
|
|
|
image_tags = soup.find_all('img') |
|
|
|
|
|
os.makedirs('chord_images', exist_ok=True) |
|
|
|
|
|
with ZipFile('chord_images.zip', 'w') as zipf: |
|
for i, img in enumerate(image_tags): |
|
img_url = img['src'] |
|
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.") |
|
|