

def fetchEntries(self, all=False):
    'GETs the corresponding chart data from Billboard.com, then parses\n        the data. Makes use of BeautifulSoup.\n        '
    if self.latest:
        url = ('http://www.billboard.com/charts/%s' % self.name)
    else:
        url = ('http://www.billboard.com/charts/%s/%s' % (self.name, self.date))
    html = downloadHTML(url)
    soup = BeautifulSoup(html, 'html.parser')
    prevLink = soup.find('a', {
        'title': 'Previous Week',
    })
    if prevLink:
        self.previousDate = prevLink.get('href').split('/')[(- 1)]
    currentTime = soup.find('time')
    if currentTime:
        self.date = currentTime.get('datetime')
    for entrySoup in soup.find_all('article', {
        'class': 'chart-row',
    }):
        basicInfoSoup = entrySoup.find('div', 'chart-row__title').contents
        title = basicInfoSoup[1].string.strip()
        if basicInfoSoup[3].find('a'):
            artist = basicInfoSoup[3].a.string.strip()
        else:
            artist = basicInfoSoup[3].string.strip()

        def getRowValue(rowName):
            selector = (('div.chart-row__' + rowName) + ' .chart-row__value')
            return entrySoup.select_one(selector).string.strip()
        peakPos = int(getRowValue('top-spot'))
        lastPos = getRowValue('last-week')
        lastPos = (0 if (lastPos == '--') else int(lastPos))
        weeks = int(getRowValue('weeks-on-chart'))
        rank = int(entrySoup.select_one('.chart-row__current-week').string.strip())
        change = (lastPos - rank)
        if (lastPos == 0):
            if (weeks > 1):
                change = 'Re-Entry'
            else:
                change = 'New'
        elif (change > 0):
            change = ('+' + str(change))
        else:
            change = str(change)
        spotifyID = entrySoup.get('data-spotifyid')
        if spotifyID:
            spotifyLink = ('https://embed.spotify.com/?uri=spotify:track:' + spotifyID)
        else:
            spotifyID = ''
            spotifyLink = ''
        self.entries.append(ChartEntry(title, artist, peakPos, lastPos, weeks, rank, change, spotifyID, spotifyLink))
    for entry in self.entries:
        if (entry.change == 'New'):
            entry.change = 'Hot Shot Debut'
            break

dataset/ETHPy150Open guoguo12/billboard-charts/billboard.py ChartData.fetchEntries/original