I am trying to scrape SVG tags from a website. The issue is when I manually copy the SVG tag and save it (for example image.svg) it perfect., but when scraping and save as .svg file the image is broken and error.
here is the code:
from urllib.request import Request from bs4 import BeautifulSoup as soup image_url = 'https://www.hudl.com/' request = Request(image_url, headers={'User-Agent': 'Mozilla/5.0'}) client = urlRequest(request) # time.sleep(1) data = client.read() time.sleep(2) # image data_soup = soup(data, 'html.parser') image_ = data_soup.find('div', {'class': 'mobile-toggle'}) image_ = image_.find('svg')
drawing-areain the page content. Are you targetting the correct class name?