MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / fetch_url

Function fetch_url

web-scraper/scripts/fetch_url.py:212–226  ·  view source on GitHub ↗

Fetch content from a URL and return as markdown.

(url: str, timeout: int = 30)

Source from the content-addressed store, hash-verified

210
211
212def fetch_url(url: str, timeout: int = 30) -> str:
213 """Fetch content from a URL and return as markdown."""
214 if HAS_REQUESTS:
215 html_content = fetch_with_requests(url, timeout)
216 else:
217 html_content = fetch_with_urllib(url, timeout)
218
219 # Check if it's an error message
220 if html_content.startswith("Error") or html_content.startswith("HTTP Error") or html_content.startswith("URL Error"):
221 return html_content
222
223 # Convert to markdown
224 parser = HTMLToMarkdown()
225 parser.feed(html_content)
226 return parser.get_markdown()
227
228
229def main():

Callers 1

mainFunction · 0.85

Calls 4

get_markdownMethod · 0.95
fetch_with_requestsFunction · 0.85
fetch_with_urllibFunction · 0.85
HTMLToMarkdownClass · 0.85

Tested by

no test coverage detected