def get_all_links html soup BeautifulSoup html lxml tds soup find tabl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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