def getSalesChartFromURL(self, URL): page = urllib2.urlopen(URL) soup = BeautifulSoup(page.read()) songs = soup.findAll(attrs = {'class' : 'latc_song'}) chart = [] for song in songs: rank = stringToInt(song.contents[0].text) lastWeek = song.contents[2].text if lastWeek == 'New': lastWeek = None elif lastWeek == 'RE': lastWeek = rank else: lastWeek = stringToInt(lastWeek) peak = stringToInt(song.contents[6].text) weeksOnChart = stringToInt(song.contents[7].text) title = cleanTitle(song.contents[3].contents[0].contents[0].contents[2].contents[0].text) artist = cleanAtrist(song.contents[3].contents[0].contents[0].contents[2].contents[1].text) item = (title, artist, rank, lastWeek, peak, weeksOnChart) chart.append(item) chart.sort(key= lambda song : song[2]) return chart
def getDetailStatTableData(self, tableText, column): text = tableText.split(column) if text[0] == tableText: return None else: return stringToInt(text[1].split()[0])