Skip to content

Instantly share code, notes, and snippets.

@cdrubin
Created September 20, 2010 02:21
Show Gist options
  • Save cdrubin/587349 to your computer and use it in GitHub Desktop.
Save cdrubin/587349 to your computer and use it in GitHub Desktop.
use curl
import curl/Curl
import io/FileWriter, structs/ArrayList
main: func (args: ArrayList<String>) {
if(args length() <= 1) {
printf("Usage: %s URL\n", args[0])
exit(0)
}
url := args get(1)
fName := "tmp.html"
fw := FileWriter new(fName)
handle := Curl new()
handle setOpt(CurlOpt url, url)
handle setOpt(CurlOpt writeData, fw)
handle setOpt(CurlOpt writeFunction, func (buffer: Pointer, size: SizeT, nmemb: SizeT, fw: FileWriter) {
fw write(buffer as String, nmemb)
})
handle perform()
handle cleanup()
fw close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment