I'm new to python and trying to pull the billboard hot 100 list. I know there is a library already, but I'm practicing (and its done differently). My issue is that Billboard's list of songs doesn't match up with the artists because the syntax of selecting the artist changes between an "a" element and a "span" element. How do I include both types of elements which both contain [@class="chart-row__artist"].
Currently I have:
artists = [x.strip() for x in tree.xpath('//a[@class="chart-row__artist"]/text()')]
but this pulls up songs as well with span:
artists = [x.strip() for x in tree.xpath('//span[@class="chart-row__artist"]/text()')]
It alternates on the page. Any suggestions?