-
Notifications
You must be signed in to change notification settings - Fork 1
/
lombrico.c
executable file
·115 lines (75 loc) · 2.87 KB
/
lombrico.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <stdio.h>
#include <string.h>
#include "rep.h"
#include "outputDblpParser.h"
#include "parserIEEE.h"
#include "parserACM.h"
#include "connector.h"
int main(int argc, char* argv[]) {
char *url;
char **urlsIeee;
char choose;
char contentWoAuthor;
int i, numberOfIeeePages;
referencesList refList = NULL;
do {
printf("\nThis operation will delete some of the files in the directory 'outputForDblp'.\nAre you sure that you want to continue?(y/n)");
scanf("%c", &choose);
} while(choose!='y' && choose!='n');
if(choose=='n') {
return 0;
}
if(argv[1]) {
downloadFromUrl(argv[1]);
} else {
printf("Error - You've to pass the url of the website to download.\n");
return 0;
}
/*
*Checking which site are we talkin about to call the corresponding
*parser function
*/
if(strstr(argv[1],"http://ieeexplore.ieee.org/")!=NULL) {
printf("%s\n", "Type: IEEE");
do {
printf("\nDo you want to insert the content without authors in the final html page?(y/n)");
scanf("%*c %c", &contentWoAuthor);
} while(contentWoAuthor!='y' && contentWoAuthor!='n');
printf("Parsing the web page.\n");
urlsIeee = firstParserIEEE(argv[1]);
for(numberOfIeeePages=0; strcmp(urlsIeee[numberOfIeeePages],"end")!=0; numberOfIeeePages++);
printf("Found %d pages.\n",numberOfIeeePages);
for(i=0; i<numberOfIeeePages; i++) {
//printf("URL %d: %s\n", i+1, urlsIeee[i]);
printf("Downloading web page number %d.\n",i+1);
downloadFromUrl(urlsIeee[i]);
printf("Parsing web page number %d.\n",i+1);
secondParserIEEE(&refList);
printf("Building the HTML page 'outputForDblp-%d.html'.\n",i+1);
outputDblpParser(refList,numberOfIeeePages,i+1,contentWoAuthor);
refList = NULL;
}
//Removing the temporary file used only for parsing
unlink("tmp.txt");
} else {
if(strstr(argv[1],"http://portal.acm.org/")!=NULL) {
printf("%s\n", "\nType: ACM");
/*
*url contains the url of the table of contents for the site in argument argv[1]
*/
printf("Parsing the web page.\n");
url = firstParserACM();
//printf("Url di TOCs:\n%s", url);
printf("Downloading the table of contents.\n");
downloadFromUrl(url);
printf("Parsing the table of contents.\n");
secondParserAcm(&refList);
printf("Building the HTML page.\n");
outputDblpParser(refList,1,1,'n');
//Removing the temporary file used only for parsing
unlink("tmp.txt");
}
}
printf("\nCheck out the output in the 'outputForDblp' directory.\n\n");
return 0;
}