Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

url_extracter - C Code Bank


url_extracter
This will extract all the links in a .html or .htm file saved in the computer.
                /**
*@Auther  :Tharindra Galahena
*@Project :Url Extracter
*@Date    :21/01/2011  
*/

#include <stdio.h>
#include <string.h>

FILE *f, *fp;

extract(char const *input, char const *output){
	
f = fopen(input, "r");
fp = fopen(output, "w");

fseek(f, 0L, SEEK_END); 
int size = ftell(f);


fseek(f, 0L, SEEK_SET);
char name[size];
int j;
char c;
for(j = 0; j < size; j++){
	name[j] = getc(f);
}

int i;
for(i = 0; i < size; i++){
	if(name[i] == 'h'|| name[i] =='H'){
		if(name[i+1] =='r'|| name[i+1] =='R'){
			if(name[i+2] == 'e'|| name[i+2] =='E'){
				if(name[i+3] =='f'|| name[i+3] =='F'){
					i += 6;
					while(name[i] != '"' && name[i] !='\''){
						fputc(name[i],fp);
						i++;
					}
					fputc('\n',fp);
				}
			}
		}
	}
	i++;
}
close(f);
close(fp);
}
int main(int argc, char **argv){

if(argc <= 2){
    printf("USAGE:\n\n");
    printf("url [input file] [link file]\n\n");
    return(0);
}

printf("Extracting Links...\n");
extract(argv[1], argv[2]);
printf("Links are extracted!\n");

return(1);
}

            
Comments
Sorry but there are no comments to display