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

Function main

web-scraper/scripts/fetch_url.py:229–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

227
228
229def main():
230 parser = argparse.ArgumentParser(description='Fetch web page content and convert to markdown')
231 parser.add_argument('url', help='URL to fetch')
232 parser.add_argument('--timeout', type=int, default=30, help='Request timeout in seconds (default: 30)')
233 parser.add_argument('--max-length', type=int, default=100000, help='Maximum output length (default: 100000)')
234 parser.add_argument('--raw', action='store_true', help='Output raw HTML instead of markdown')
235
236 args = parser.parse_args()
237
238 if args.raw:
239 if HAS_REQUESTS:
240 content = fetch_with_requests(args.url, timeout=args.timeout)
241 else:
242 content = fetch_with_urllib(args.url, timeout=args.timeout)
243 else:
244 content = fetch_url(args.url, timeout=args.timeout)
245
246 # Truncate if too long
247 if len(content) > args.max_length:
248 content = content[:args.max_length] + "\n\n[Content truncated...]"
249
250 print(content)
251
252
253if __name__ == '__main__':

Callers 1

fetch_url.pyFile · 0.70

Calls 3

fetch_with_requestsFunction · 0.85
fetch_with_urllibFunction · 0.85
fetch_urlFunction · 0.85

Tested by

no test coverage detected