Created
June 30, 2024 15:28
-
-
Save felipedavi/ce6a5ed89119db3286a6039c0767d5fc to your computer and use it in GitHub Desktop.
Bitcoin in Real (Google Finance - Web scraping - Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests, re | |
from bs4 import BeautifulSoup | |
url = 'https://www.google.com/finance/quote/BTC-BRL' | |
headers = { | |
'Accept-Language': 'pt-BR' | |
} | |
response = requests.get(url, headers=headers) | |
if response.status_code == 200: | |
soup = BeautifulSoup(response.text, 'html.parser') | |
price_element = soup.find('div', attrs={'class': 'YMlKec fxKbKc'}) | |
bitcoin_price = price_element.text.strip() | |
print(f'R$ {bitcoin_price}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment