I have the below code:
from bs4 import BeautifulSoup as bs
soup = bs(requests.get(url).content, "html.parser")
for img in tqdm(soup.find_all("img"), "Extracting images"):
img_url = str(img.attrs.get("data-src"))
print(img_url)
img_url = str(img.attrs.get("data"))
print(img_url)
It works when I trying to get the data form src, but when I try to get the data from data-src” it does not work when there is a Hyphen
<img alt="" class="lazy" src="https://www.url.com/assets/images/new-search-icon.svg"/>
<img alt="" class="lazyload" data-src="https://url.tv/bcci/photos/1354/887cffe6-0664-4146-9e7b-27b83d71db56.jpg"/>
Any idea how I can get the details from attribute with a hyphen?