Racket Cookbook
1 How to Download Files Using Racket
1.1 Problem
1.2 Solution
1.3 Discussion
0

Racket Cookbook

1 How to Download Files Using Racket

1.1 Problem

Suppose you want to download the following zip archive to your computer using Racket: https://s3.amazonaws.com/spark-public/ml/exercises/on-demand/machine-learning-ex1.zip (apropos: this is the first programming assignment of Andrew Ng’s Machine Learning course).

1.2 Solution

#lang racket

 

(require net/url)

 

(define URL "https://s3.amazonaws.com/spark-public/ml/exercises/on-demand/machine-learning-ex1.zip")

 

(call-with-output-file "/tmp/out.zip"

    (λ (out)

      (copy-port (get-pure-port (string->url URL)) out)))

1.3 Discussion

Also see:

Home Resume Projects Reading log Movies log Now