google web proxy
To upload files, please first save the app
import streamlit as st
import requests
from bs4 import BeautifulSoup
st.title("Web Proxy Viewer")
st.write("Enter a URL to view its contents through a CORS proxy")
url = st.text_input("Enter URL:", "https://example.com")
if st.button("Fetch Content"):
if url:
try:
# NOTE: Using corsproxy.io because we're in a WASM environment. If running locally,
# you can remove the corsproxy.io prefix. Some websites don't work with the proxy,
# in those cases try removing the proxy prefix.
proxied_url = f"https://corsproxy.io/?{url}"
response = requests.get(proxied_url)
response.raise_for_status()
# Parse HTML content
soup = BeautifulSoup(response.text, 'html.parser')
# Display original URL
st.subheader("Original URL")
st.write(url)
# Display title if found
if soup.title:
st.subheader("Page Title")
st.write(soup.title.string)
# Display raw content
st.subheader("Page Content")
st.code(response.text, language="html")
except Exception as e:
st.error(f"Error fetching content: {str(e)}")
else:
st.warning("Please enter a URL")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?