| import streamlit as st |
| import requests |
| from bs4 import BeautifulSoup |
| import re |
|
|
| def main(): |
| st.title("Enhanced Proxy Server") |
|
|
| |
| url = st.text_input("Enter URL to proxy:", "https://www.example.com") |
|
|
| |
| st.write("Proxying requests to:", url) |
|
|
| |
|
|
| |
| user_input = st.text_input("Enter request parameters (if any):", "") |
| if st.button("Send Request"): |
| |
| response = make_request(url, user_input) |
|
|
| |
| proxied_html = proxy_links_and_js(url, response.text) |
|
|
| |
| st.subheader("Original HTML:") |
| st.markdown(response.text) |
|
|
| st.subheader("Proxied HTML:") |
| st.markdown(proxied_html) |
|
|
| def make_request(url, params): |
| |
| response = requests.get(url, params=params) |
| return response |
|
|
| def proxy_links_and_js(base_url, html_content): |
| |
| soup = BeautifulSoup(html_content, "html.parser") |
|
|
| |
| links = soup.find_all("a", href=True) |
| for link in links: |
| |
| link["href"] = f"/proxy?target={base_url}/{link['href']}" |
|
|
| |
| script_tags = soup.find_all("script", src=True) |
| for script_tag in script_tags: |
| |
| script_tag["src"] = f"/proxy?target={base_url}/{script_tag['src']}" |
|
|
| |
| return str(soup) |
|
|
| if __name__ == "__main__": |
| main() |
|
|