def get_all_links(html): soup = BeautifulSoup(html, 'lxml') tds = soup.find('table', id='currencies-all').find_all('td', class_='currency-name') links = [] for td in tds: a = td.find('a', class_='currency-name-container').get('href') link = 'https://coinmarketcap.com' + a links.append(link) return links def text_before_word(text, word): line = text.split(word)[0].strip() return line