Update main.py
Browse files
main.py
CHANGED
@@ -117,20 +117,14 @@ def proxy(path):
|
|
117 |
# Update the link's href attribute
|
118 |
link['href'] = google_search_url
|
119 |
|
120 |
-
#
|
121 |
for img in soup.find_all('img'):
|
122 |
-
# Create button element
|
123 |
-
button = soup.new_tag('button')
|
124 |
img_src = img['src']
|
125 |
if not img_src.startswith('http'):
|
126 |
img_src = urljoin(TARGET_BASE_URL, img_src)
|
127 |
-
from urllib.parse import quote
|
128 |
proxy_url = f"/proxy_image?url={quote(img_src)}"
|
129 |
-
|
130 |
-
|
131 |
-
button.string = 'Показать изображение'
|
132 |
-
# Replace image with button
|
133 |
-
img.replace_with(button)
|
134 |
|
135 |
# Create a Flask response object with filtered content
|
136 |
response = Response(
|
|
|
117 |
# Update the link's href attribute
|
118 |
link['href'] = google_search_url
|
119 |
|
120 |
+
# Update image sources to use our proxy
|
121 |
for img in soup.find_all('img'):
|
|
|
|
|
122 |
img_src = img['src']
|
123 |
if not img_src.startswith('http'):
|
124 |
img_src = urljoin(TARGET_BASE_URL, img_src)
|
|
|
125 |
proxy_url = f"/proxy_image?url={quote(img_src)}"
|
126 |
+
img['src'] = proxy_url
|
127 |
+
img['style'] = 'max-width: 100%; height: auto;'
|
|
|
|
|
|
|
128 |
|
129 |
# Create a Flask response object with filtered content
|
130 |
response = Response(
|