Get a specific HTML attribute using Beautifulsale
I'm trying to capture (catch) an attribute called srcset
inside a tag img
<img _ngcontent-games2-c5="" class="mdc-image-list__image ng-lazyloaded" offset="100" src="/assets/img/lazy-load.jpg" srcset="https://juegosv.com/wp-content/uploads/2019/06/powerline-io.jpg" alt="Powerline.io">
My code written in Python is as follows:
from bs4 import BeautifulSoup
from requests import get
url = get("http://jogos.io").text
soup = BeautifulSoup(url, "html5lib")
uls = soup.find("ul", {
"class": "mdc-image-list"
})
imgs = uls.findAll("img")
print(f"{imgs}\n")
It returns me a list with multiple image tags:
[<img _ngcontent-sc7="" alt="Powerline.io" class="mdc-image-list__image" offset="100" src="/assets/img/lazy-load.jpg"/>, <img _ngcontent-sc7="" alt="tacticscore.io" class="mdc-image-list__image" offset="100" src="/assets/img/lazy-load.jpg"/>, ...]
But the attribute srcset
does not appear in any of them. I can only see this attribute if i Inspect Element inside the site through the browser.
Questions: How do you do that? What do I need to do?
0