Compare commits

...

1 commit

Author SHA1 Message Date
3b80d08881 Debug 2020-12-26 23:09:38 +01:00
3 changed files with 14 additions and 3 deletions

6
http.c
View file

@ -20,6 +20,10 @@ char* request(char *url)
CURL *httpHandler = curl_easy_init();
CURLcode return_code;
if(httpHandler) {
for(int i=0;i<128;i++)
{
fprintf(stderr,"%x",url[i]);
}
curl_easy_setopt(httpHandler,CURLOPT_URL, url);
curl_easy_setopt(httpHandler,CURLOPT_WRITEFUNCTION, httpResponseCallback);
curl_easy_setopt(httpHandler,CURLOPT_USERAGENT, "cWikiBot/0.1 (https://git.zom.bi/cpp/cWikiBot; cpp@zom.bi) libcurl4/7.64.0");
@ -33,7 +37,7 @@ char* request(char *url)
}
if(return_code != CURLE_OK)
{
fprintf(stderr, "HTTP Error: %s",curl_easy_strerror(return_code));
fprintf(stderr, "HTTP Error: %s\n",curl_easy_strerror(return_code));
return NULL;
}
return httpResponse.response;

View file

@ -13,8 +13,10 @@ json_object* query_lichess(char* username)
char* api_base = "https://lichess.org/api/user/";
char user_url[128];
int retries = 5;
strcpy(user_url,api_base);
strcat(user_url,username);
//strcpy(user_url,api_base);
//strcat(user_url,username);
int user_url_length = sprintf(user_url,"%s%s\0",api_base,username);
user_url[user_url_length]=0;
printf("querying %s\n",user_url);
char* http_response = request(user_url);
while(http_response == NULL)

5
main.c
View file

@ -41,8 +41,11 @@ int main(int argc, char **argv)
}
fputs("lichess_id,name\n",output);
char line [128];
int j=0;
while(fgets(line, sizeof line, playersfile) != NULL)
{
printf("%i",j);
j++;
char outline[256];
char name[128];
line[strlen(line)-1] = '\0';
@ -65,6 +68,8 @@ int main(int argc, char **argv)
sprintf(outline, "%s,%s\n",line,name);
printf("OK\n");
fputs(outline,output);
fclose(output);
fopen("output.csv","a");
}
fclose(output);
fclose(playersfile);