Make number of records to fetch a command line argument.
This commit is contained in:
parent
24b4a49cc7
commit
d9e065e6cf
14
fetcher.cc
14
fetcher.cc
|
@ -17,12 +17,13 @@
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
std::string exbid, apikey;
|
std::string exbid, apikey;
|
||||||
if (argc !=5 ) {
|
if (argc !=7 ) {
|
||||||
std::cout<<"Usage: "<<argv[0] <<" -e <exhibition id> -k <api key>"<<std::endl;
|
std::cout<<"Usage: "<<argv[0] <<" -e <exhibition id> -k <api key> -e <number of records>"<<std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt (argc, argv, "e:k:")) != -1)
|
int numrec = 0;
|
||||||
|
while ((c = getopt (argc, argv, "e:k:n:")) != -1)
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -31,11 +32,16 @@ int main(int argc, char *argv[])
|
||||||
case 'k':
|
case 'k':
|
||||||
apikey = optarg;
|
apikey = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
numrec = atoi(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
std::cout<<numrec<<" records to fetch\n";
|
||||||
|
int numfetches = (numrec / 100) + 1;
|
||||||
char url[256], outfilename[64];
|
char url[256], outfilename[64];
|
||||||
for (int i = 0; i<4; i++) {
|
for (int i = 0; i<numfetches; i++) {
|
||||||
snprintf(url, sizeof url, "https://api.dimu.org/api/solr/select?q=Kosta&wt=json&fq=(artifact.exhibitionUids:\"%s\")&start=%d&rows=100&api.key=%s", exbid.c_str(), i*100, apikey.c_str());
|
snprintf(url, sizeof url, "https://api.dimu.org/api/solr/select?q=Kosta&wt=json&fq=(artifact.exhibitionUids:\"%s\")&start=%d&rows=100&api.key=%s", exbid.c_str(), i*100, apikey.c_str());
|
||||||
|
|
||||||
std::cout<<url<<"\n";
|
std::cout<<url<<"\n";
|
||||||
|
|
Loading…
Reference in New Issue