Skip to content

Instantly share code, notes, and snippets.

@xicalango
Created October 16, 2013 20:44
Show Gist options
  • Save xicalango/7014527 to your computer and use it in GitHub Desktop.
Save xicalango/7014527 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
const char* wget_command = "wget ""%s"" -O ""%s""";
char run_command[1000] = {0};
if( argc != 3 )
{
printf("Call %s <url> <outputfile>\n", argv[0]);
return EXIT_FAILURE;
}
int result = snprintf( run_command, 1000, wget_command, argv[1], argv[2] );
if( result < 0 || result > 1000 )
{
perror("parameters too long");
}
system( run_command );
return EXIT_SUCCESS;
}
#import the module needed
import urllib2
import sys
#make a request to the server, and place response in a variable
response = urllib2.urlopen(sys.argv[1])
#response object is a file like object
#read the data from the response into a string
html_string = response.read()
#write to output
with open(sys.argv[2], "w") as f:
f.write(html_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment