Skip to content

Instantly share code, notes, and snippets.

@sepisoad
Created August 29, 2018 11:46
Show Gist options
  • Save sepisoad/4af65c2e57cc7a4f69cf97ed6ae26ce6 to your computer and use it in GitHub Desktop.
Save sepisoad/4af65c2e57cc7a4f69cf97ed6ae26ce6 to your computer and use it in GitHub Desktop.
fetch urls from a url
#lang racket
(require net/url)
(if (< (vector-length (current-command-line-arguments)) 1)
(display "please define url\n")
(display "please wait ...\n"))
(define URL (vector-ref (current-command-line-arguments) 0))
(display (string-append URL "\n"))
(let ([html (call/input-url
(string->url URL)
get-pure-port
port->string)])
(let ([matches (regexp-match* #rx"href=\"https?://.*?\"" html)])
(for ([m matches])
(display (substring m 6 (- (string-length m) 1)))
(newline))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment