So just run the example program (unmodified) once for each time your need a URL fetched. I fails to see where the issue is.

As an aside, you are on a UNIX machine... have you ever heard of wget or curl?