File size: 2,460 Bytes
a4ea8a9 5add52e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import streamlit as st
from googlesearch import search
import requests
from bs4 import BeautifulSoup
# Function to fetch search results
def fetch_search_results(query, num_results=5):
results = []
try:
for url in search(query, num=num_results, stop=num_results, pause=2):
results.append(url)
except Exception as e:
st.error(f"Error fetching search results: {e}")
return results
# Function to fetch website preview
def fetch_website_preview(url):
try:
response = requests.get(url, timeout=5)
soup = BeautifulSoup(response.content, "html.parser")
title = soup.title.string if soup.title else "No title"
return title, url
except Exception as e:
return "Error loading website", None
# Mask IP address using proxy
def secure_request(url, proxy=None):
proxies = {"http": proxy, "https": proxy} if proxy else None
try:
response = requests.get(url, proxies=proxies, timeout=5)
return response.status_code, response.content
except Exception as e:
return None, str(e)
# Streamlit app starts here
st.title("Secure Chrome Search with IP Masking")
st.write("Search the web securely, view results, and mask your IP address.")
# User input
query = st.text_input("Enter search query:", "")
# Search results
if query:
st.write("Fetching search results...")
results = fetch_search_results(query)
if results:
st.write("Top Results:")
for idx, url in enumerate(results):
st.markdown(f"{idx+1}. [Visit Site]({url})")
# Select website to preview
selected_url = st.selectbox("Select a website to preview:", results)
if selected_url:
st.write("Website Preview:")
title, preview_url = fetch_website_preview(selected_url)
st.write(f"**Title:** {title}")
st.markdown(f"[Visit Site in Browser]({preview_url})")
else:
st.write("No results found.")
# Mask IP section
proxy = st.text_input("Enter proxy (e.g., http://<proxy-ip>:<port>):", "")
if proxy:
test_url = st.text_input("Enter URL to test secure connection:", "http://httpbin.org/ip")
if st.button("Test Secure Connection"):
status, response = secure_request(test_url, proxy=proxy)
if status:
st.success(f"Response Status: {status}")
st.write(response.decode("utf-8"))
else:
st.error(f"Error: {response}") |