I want to get src
url from all this html using python.
I had this code to get text:
avatar = html.find(class_ = "image-container image-container-player image-container-bigavatar")
print(avatar)
<div ><a href="/players/1227965603"><img alt="twitch.tv/gh0stluko" data-tooltip-url="/players/1227965603/tooltip" rel="tooltip-remote" src="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/b6/b6e83cac75233208d4bb79811d768fdf17dbd46e_full.jpg" title="twitch.tv/gh0stluko"/></a></div>
CodePudding user response:
Assuming you only want to find images, add "img"
as the first argument to find()
.
Then you can look at the ["src"]
attribute directly:
avatar = html.find("img", class_="...")
print(avatar["src"])