Created
October 16, 2013 20:44
-
-
Save xicalango/7014527 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#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; | |
} |
This file contains hidden or 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
#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