Update Modules/Web_Fetch.py
Browse files- Modules/Web_Fetch.py +19 -9
Modules/Web_Fetch.py
CHANGED
|
@@ -239,19 +239,21 @@ def Web_Fetch(
|
|
| 239 |
|
| 240 |
|
| 241 |
def build_interface() -> gr.Interface:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
return gr.Interface(
|
| 243 |
-
fn=
|
| 244 |
inputs=[
|
| 245 |
gr.Textbox(label="URL", placeholder="https://example.com/article", max_lines=1),
|
| 246 |
gr.Slider(minimum=0, maximum=20000, value=3000, step=100, label="Max Characters", info="0 = no limit (full page), default 3000"),
|
| 247 |
-
gr.Textbox(
|
| 248 |
-
label="Strip Selectors",
|
| 249 |
-
placeholder=".header, .footer, nav, .sidebar",
|
| 250 |
-
value="",
|
| 251 |
-
max_lines=1,
|
| 252 |
-
info="CSS selectors to remove (comma-separated)",
|
| 253 |
-
),
|
| 254 |
-
gr.Checkbox(label="URL Scraper", value=False, info="Extract only links instead of content"),
|
| 255 |
gr.Slider(
|
| 256 |
minimum=0,
|
| 257 |
maximum=100000,
|
|
@@ -260,6 +262,14 @@ def build_interface() -> gr.Interface:
|
|
| 260 |
label="Offset",
|
| 261 |
info="Character offset to start from (use next_cursor from previous call for pagination)",
|
| 262 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
],
|
| 264 |
outputs=gr.Markdown(label="Extracted Content"),
|
| 265 |
title="Web Fetch",
|
|
|
|
| 239 |
|
| 240 |
|
| 241 |
def build_interface() -> gr.Interface:
|
| 242 |
+
# Wrapper to preserve original Web_Fetch signature while reordering UI inputs
|
| 243 |
+
def _web_fetch_ui(url: str, max_chars: int, offset: int, strip_selectors: str, url_scraper: bool) -> str:
|
| 244 |
+
return Web_Fetch(
|
| 245 |
+
url=url,
|
| 246 |
+
max_chars=max_chars,
|
| 247 |
+
strip_selectors=strip_selectors,
|
| 248 |
+
url_scraper=url_scraper,
|
| 249 |
+
offset=offset,
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
return gr.Interface(
|
| 253 |
+
fn=_web_fetch_ui,
|
| 254 |
inputs=[
|
| 255 |
gr.Textbox(label="URL", placeholder="https://example.com/article", max_lines=1),
|
| 256 |
gr.Slider(minimum=0, maximum=20000, value=3000, step=100, label="Max Characters", info="0 = no limit (full page), default 3000"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
gr.Slider(
|
| 258 |
minimum=0,
|
| 259 |
maximum=100000,
|
|
|
|
| 262 |
label="Offset",
|
| 263 |
info="Character offset to start from (use next_cursor from previous call for pagination)",
|
| 264 |
),
|
| 265 |
+
gr.Textbox(
|
| 266 |
+
label="Strip Selectors",
|
| 267 |
+
placeholder=".header, .footer, nav, .sidebar",
|
| 268 |
+
value="",
|
| 269 |
+
max_lines=1,
|
| 270 |
+
info="CSS selectors to remove (comma-separated)",
|
| 271 |
+
),
|
| 272 |
+
gr.Checkbox(label="URL Scraper", value=False, info="Extract only links instead of content"),
|
| 273 |
],
|
| 274 |
outputs=gr.Markdown(label="Extracted Content"),
|
| 275 |
title="Web Fetch",
|