A Step by Step Guide to Deploy Streamlit App Using Cloudflared, BeautifulSoup, Pandas, Plotly for Real-Time Cryptocurrency Web Scraping and Visualization

In this tutorial, we’ll walk through a reliable and hassle-free approach using Cloudflared, a tool by Cloudflare that provides a secure, publicly accessible link to your Streamlit app. By the end of this guide, we will achieve a fully functional cryptocurrency dashboard that dynamically scrapes and visualizes real-time price data from CoinMarketCap. You can track […] The post A Step by Step Guide to Deploy Streamlit App Using Cloudflared, BeautifulSoup, Pandas, Plotly for Real-Time Cryptocurrency Web Scraping and Visualization appeared first on MarkTechPost.

Mar 6, 2025 - 06:34
 0
A Step by Step Guide to Deploy Streamlit App Using Cloudflared, BeautifulSoup, Pandas, Plotly for Real-Time Cryptocurrency Web Scraping and Visualization

In this tutorial, we’ll walk through a reliable and hassle-free approach using Cloudflared, a tool by Cloudflare that provides a secure, publicly accessible link to your Streamlit app. By the end of this guide, we will achieve a fully functional cryptocurrency dashboard that dynamically scrapes and visualizes real-time price data from CoinMarketCap. You can track the top 10 cryptocurrencies, compare their prices and market capitalizations, and view interactive charts for better insights.

!pip install streamlit requests beautifulsoup4 pandas matplotlib plotly
!npm install -g localtunnel

First, the above command installs the necessary dependencies for building and deploying a Streamlit-based cryptocurrency dashboard. The first command installs essential Python libraries like Streamlit for the web app, BeautifulSoup4 for web scraping, Pandas for data 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.express as px


# Function to scrape cryptocurrency prices
def scrape_crypto_prices():
    url = "https://coinmarketcap.com/"
    headers = {"User-Agent": "Mozilla/5.0"}
    response = requests.get(url, headers=headers)
   
    if response.status_code != 200:
        return pd.DataFrame(), "Error fetching data."
   
    soup = BeautifulSoup(response.text, "html.parser")
    rows = soup.select("tbody tr")[:10]  # Get top 10 cryptocurrencies
   
    data = []
    for row in rows:
        columns = row.find_all("td")
        name = columns[2].find("p").text  # Crypto name
        symbol = columns[2].find("p", class_="coin-item-symbol").text  # Symbol
        price = columns[3].text  # Price
        change = columns[4].text  # % Change
        market_cap = columns[6].text  # Market Cap
        data.append([name, symbol, price, change, market_cap])
   
    return pd.DataFrame(data, columns=["Name", "Symbol", "Price", "% Change", "Market Cap"]), None


# Streamlit UI
st.title("                        </div>
                                            <div class=
                            
                                read more