guoguo12 / billboard-charts

Python API for downloading Billboard charts.
https://pypi.python.org/pypi/billboard.py
MIT License
389 stars 117 forks source link

image url not working? #70

Closed nebudev14 closed 8 months ago

nebudev14 commented 4 years ago

Every time I try to use

song = chart[0] print(song.image)

It keeps returning None (for all songs). Is there any reason for this?

guoguo12 commented 4 years ago

Thanks, looks like it's broken.

harshjadon9 commented 4 years ago

same here bro!

guoguo12 commented 4 years ago

I guess "broken" isn't entirely accurate, since the code reads

# TODO: Parse the image
image = None

This would be a great first PR for a beginner!

delaneyestrada commented 4 years ago

I took a look at it and attempted a fix.

Looks like the first 10 images on each page are loaded into: <span class="chart-element__image flex--no-shrink" style="background-image: url('https://charts-static.billboard.com/img/2020/02/jack-harlow-16c-whats-poppin-fly-53x53.jpg');"></span>.

The rest of the equivalent spans come up as: <span class="chart-element__image flex--no-shrink" style=""></span> My guess is that the site is using javascript to add the 'background-image' style as the page loads.

If that's the case, the only fix would be to add something like selenium in specifically for the images.

soubenz commented 3 years ago

Fixed here #80

officicalalkhaldi commented 8 months ago

I've Fixed it

on line 355 change this image = None to image = entrySoup.select_one("li:nth-child(2) img").get("data-lazy-src", None)

Happy Coding y'all

guoguo12 commented 8 months ago

Thanks! Merged. The latest version (7.0.1) contains the fix.