On this tutorial, we’ll stroll by way of a dependable and hassle-free method utilizing Cloudflared, a software by Cloudflare that gives a safe, publicly accessible hyperlink to your Streamlit app. By the top of this information, we’ll obtain a completely purposeful cryptocurrency dashboard that dynamically scrapes and visualizes real-time value knowledge from CoinMarketCap. You’ll be able to monitor the highest 10 cryptocurrencies, examine their costs and market capitalizations, and consider interactive charts for higher insights.
!pip set up streamlit requests beautifulsoup4 pandas matplotlib plotly
!npm set up -g localtunnel
First, the above command installs the required dependencies for constructing and deploying a Streamlit-based cryptocurrency dashboard. The primary command installs important Python libraries like Streamlit for the online app, BeautifulSoup4 for net scraping, Pandas for knowledge manipulation, and Plotly for interactive visualizations. The second command installs LocalTunnel, which creates a public URL for accessing the Streamlit app from Colab.
%%writefile app.py
import streamlit as st
import requests
from bs4 import BeautifulSoup
import pandas as pd
import plotly.categorical as px
# Perform to scrape cryptocurrency costs
def scrape_crypto_prices():
url = "https://coinmarketcap.com/"
headers = {"Consumer-Agent": "Mozilla/5.0"}
response = requests.get(url, headers=headers)
if response.status_code != 200:
return pd.DataFrame(), "Error fetching knowledge."
soup = BeautifulSoup(response.textual content, "html.parser")
rows = soup.choose("tbody tr")[:10] # Get high 10 cryptocurrencies
knowledge = []
for row in rows:
columns = row.find_all("td")
title = columns[2].discover("p").textual content # Crypto title
image = columns[2].discover("p", class_="coin-item-symbol").textual content # Image
value = columns[3].textual content # Value
change = columns[4].textual content # % Change
market_cap = columns[6].textual content # Market Cap
knowledge.append([name, symbol, price, change, market_cap])
return pd.DataFrame(knowledge, columns=["Name", "Symbol", "Price", "% Change", "Market Cap"]), None
# Streamlit UI
st.title("📈 Reside Cryptocurrency Costs")
knowledge, error = scrape_crypto_prices()
if error:
st.error(error)
else:
st.dataframe(knowledge)
knowledge["Price"] = knowledge["Price"].change({"$": "", ",": ""}, regex=True).astype(float)
fig = px.bar(knowledge, x="Image", y="Value", colour="Identify", title="Prime 10 Cryptos by Value")
st.plotly_chart(fig)
fig_market_cap = px.pie(knowledge, names="Identify", values="Market Cap", title="Market Cap Distribution")
st.plotly_chart(fig_market_cap)
# Footer
st.markdown("🔄 Information scraped from CoinMarketCap. Up to date in real-time.")
Right here, we outline a Streamlit net software that scrapes real-time cryptocurrency costs from CoinMarketCap and shows them in an interactive dashboard. It makes use of BeautifulSoup4 to extract the highest 10 cryptocurrencies, together with their title, image, value, proportion change, and market capitalization. The scraped knowledge is processed utilizing Pandas and visualized with Plotly. The app presents a bar chart for value comparability and a pie chart for market capitalization distribution. The app shows an error message if an error happens whereas fetching knowledge. Lastly, a footer notice signifies that the information updates dynamically from CoinMarketCap.
import subprocess
import time
# Begin Streamlit within the background
subprocess.Popen(["streamlit", "run", "app.py", "--server.port=8501"])
# Look ahead to Streamlit to begin
time.sleep(5)
# Begin Cloudflare tunnel and expose the app
!./cloudflared tunnel --url http://localhost:8501 --no-autoupdate
Lastly, the above code launches the Streamlit app within the background utilizing subprocess.Popen and permits it to run on port 8501. A brief delay (time.sleep(5)) ensures the app initializes correctly earlier than beginning the Cloudflared tunnel, which creates a public URL to entry the app from Google Colab with out authentication or extra setup.
In conclusion, this tutorial supplied a step-by-step information to constructing and deploying a real-time cryptocurrency monitoring app utilizing Streamlit, BeautifulSoup, Pandas, and Plotly. We efficiently scraped stay crypto knowledge from CoinMarketCap, displayed it in an interactive dashboard, and hosted it seamlessly utilizing Cloudflared. In contrast to conventional internet hosting strategies, this method ensures simple deployment with out authentication hassles. Whether or not you’re a newbie exploring net scraping and knowledge visualization or a developer searching for a light-weight, accessible deployment methodology, this tutorial equips you with the instruments to construct and share interactive net apps effectively.
Right here is the Colab Notebook and CSV File for the above venture. Additionally, don’t overlook to observe us on Twitter and be part of our Telegram Channel and LinkedIn Group. Don’t Overlook to affix our 80k+ ML SubReddit.
🚨 Really useful Learn- LG AI Analysis Releases NEXUS: An Superior System Integrating Agent AI System and Information Compliance Requirements to Tackle Authorized Issues in AI Datasets

Asif Razzaq is the CEO of Marktechpost Media Inc.. As a visionary entrepreneur and engineer, Asif is dedicated to harnessing the potential of Synthetic Intelligence for social good. His most up-to-date endeavor is the launch of an Synthetic Intelligence Media Platform, Marktechpost, which stands out for its in-depth protection of machine studying and deep studying information that’s each technically sound and simply comprehensible by a large viewers. The platform boasts of over 2 million month-to-month views, illustrating its recognition amongst audiences.