我正在尝试获取 coinmarketcap 加密货币的价格。不幸的是,它不起作用。任何人都可以帮忙吗?
我想显示这枚硬币的价格:https ://coinmarketcap.com/currencies/bombcrypto/
我的代码:
#!/usr/bin/env python3
from bs4 import BeautifulSoup as S
import requests
c = input('bombcrypto')
url = f'https://coinmarketcap.com/currencies/{c}/'
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}
r = requests.get(url,headers=headers)
soup = S(r.content,'html.parser')
print(f'the price of {c} now is ')
x = soup.find(class_='sc-16r8icm-0 kjciSH priceTitle').text
print(x)
谢谢你