File size: 1,928 Bytes
369c20e
 
 
21e7cd4
369c20e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
050583c
369c20e
21e7cd4
 
 
 
794ebec
21e7cd4
369c20e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
050583c
794ebec
369c20e
 
 
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
import streamlit as st
import requests
from bs4 import BeautifulSoup
import re

def main():
    st.title("Enhanced Proxy Server")

    # Get URL input from the user
    url = st.text_input("Enter URL to proxy:", "https://www.example.com")

    # Display the URL
    st.write("Proxying requests to:", url)

    # Add any additional options or features as needed

    # Create a simple form to submit requests
    user_input = st.text_input("Enter request parameters (if any):", "")
    if st.button("Send Request"):
        # Make a request to the specified URL
        response = make_request(url, user_input)

        # Extract and proxy links and JavaScript requests
        proxied_html = proxy_links_and_js(url, response.text)

        # Display the original HTML in one column and the proxied HTML in another column
        st.subheader("Original HTML:")
        st.markdown(response.text)

        st.subheader("Proxied HTML:")
        st.markdown(proxied_html)

def make_request(url, params):
    # Make an HTTP GET request to the specified URL with optional parameters
    response = requests.get(url, params=params)
    return response

def proxy_links_and_js(base_url, html_content):
    # Use BeautifulSoup to parse the HTML
    soup = BeautifulSoup(html_content, "html.parser")

    # Find all links (a tags) in the HTML
    links = soup.find_all("a", href=True)
    for link in links:
        # Modify each link to be a proxied link
        link["href"] = f"/proxy?target={base_url}/{link['href']}"

    # Find all script tags with a src attribute (JavaScript)
    script_tags = soup.find_all("script", src=True)
    for script_tag in script_tags:
        # Modify each script source to be a proxied link
        script_tag["src"] = f"/proxy?target={base_url}/{script_tag['src']}"

    # Return the modified HTML with proxied links and JavaScript sources
    return str(soup)

if __name__ == "__main__":
    main()