Created
September 20, 2010 02:21
-
-
Save cdrubin/587349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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