Skip to content

Instantly share code, notes, and snippets.

@Skrylar
Created December 20, 2017 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skrylar/9c735f4a6e50c5778e02054ac1a8cfe0 to your computer and use it in GitHub Desktop.
Save Skrylar/9c735f4a6e50c5778e02054ac1a8cfe0 to your computer and use it in GitHub Desktop.
import libcurl
const
feed = "https://feeds.feedburner.com/breitbart?format=xml"
var downloaded = newstringofcap(1024)
proc onwrite(buffer: cstring; size, nitems: int; outstream: pointer): int =
let total = size * nitems
for i in 0..<total:
downloaded.add buffer[i]
return total
var handle = easy_init()
discard easy_setopt(handle, Opt_url, feed)
discard easy_setopt(handle, Opt_verbose, 1)
discard easy_setopt(handle, Opt_writefunction, onwrite)
echo easy_perform(handle)
easy_reset(handle)
echo downloaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment