Используем сайт https://coinmarketcap.com/all/views/all/
Код на python
import requests
from bs4 import BeautifulSoup
def main():
link = «https://coinmarketcap.com/all/views/all/»
links = get_urls(get_html(link))
for lin in links:
data = get_price(lin)
print (data[‘name’], data[‘cast’])
def get_price(lin):
data = requests.get(lin)
soup = BeautifulSoup(data.text,’lxml’)
name = soup.find(‘h2’).text.strip()
cast = soup.find(‘div’, class_=»priceValue»).text.strip()
data = {«name»: name, «cast»: cast}
return data
def get_html(url):
r = requests.get(url)
return r.text
def get_urls(html):
links = []
soup = BeautifulSoup(html,’lxml’)
tds = soup.find(‘tbody’).find_all(‘div’,class_=’cmc-table__column-name—narrow-layout’)
for td in tds:
a = td.find(‘a’).get(‘href’)
links.append(‘https://coinmarketcap.com’+a)
return links
if __name__==’__main__’:
main()
Результат