예제 #1
0
int main(int argc, char *argv[])
{
    int r, ret;
    short statuscode;
    char *fileBuf;              /* Pointer to downloaded data */

    ret = http_fetch(argv[1], &fileBuf, &statuscode);   /* Downloads page */
    if (ret == -1)              /* All HTTP Fetcher functions return */
        http_perror("http_fetch");      /*      -1 on error. */
    else
    {
        printf("Page successfully downloaded(%d). (%s)\n", ret, argv[1]);
        printf("%s\n", fileBuf);
        printf("-----------------%d-----------------\n", ret);
        free(fileBuf);
    }

    return 0;
}
예제 #2
0
int main(int argc, char *argv[])
	{
	int ret;
	char *url = "www.google.com";   	/* Pointer to the url you want */
	char *fileBuf;						/* Pointer to downloaded data */

	ret = http_fetch(url, &fileBuf);	/* Downloads page */
	if(ret == -1)						/* All HTTP Fetcher functions return */
		http_perror("http_fetch");		/*	-1 on error. */
	else
		printf("Page successfully downloaded. (%s)\n", url);
	
	/* 
	 * Now we have the page downloaded and stored in fileBuf, we could save it
	 *	to disk, print it out, etc.  Notice that http_fetch() is the primary
	 *	function of the library, and for a barebones request is the only
	 *	function you need (in conjunction with http_perror).  With HTTP Fetcher
	 *	you can also set User Agent, referer, and timeout values, parse
	 *	filenames, etc... see the header file (http_fetcher.h) for function
	 *	usage/information.
	 */
	 
	return 0;
	}