From 568751040761f707deeb46b7032912ac7a7dd34b Mon Sep 17 00:00:00 2001 From: Nick White Date: Sun, 24 Jul 2011 12:48:43 +0100 Subject: Retry more times, and with faster page --- getgbook.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/getgbook.c b/getgbook.c index ecd34a6..c87b1c1 100644 --- a/getgbook.c +++ b/getgbook.c @@ -68,7 +68,7 @@ Page *getpagedetail(char *bookid, char *pg, char *cookie) int main(int argc, char *argv[]) { - char *bookid, *tmp, pg[16], buf[1024], n[80], code[3], cookie[COOKIEMAX], u[1024]; + char *bookid, *tmp, pg[16], buf[1024], n[80], code[3], cookie[COOKIEMAX]; int i, c, retry; Page *page; @@ -95,11 +95,10 @@ int main(int argc, char *argv[]) if(!page->url[0]) { free(page); /* try with fresh cookie */ - if(!retry) { - snprintf(u, URLMAX, "/books?id=%s", bookid); - get("books.google.com", u, NULL, cookie, &tmp); + if(retry < 5) { + get("books.google.com", "/", NULL, cookie, &tmp); free(tmp); - retry=1; + retry++; i--; } else { fprintf(stderr, "%s not available\n", pg); @@ -125,8 +124,7 @@ int main(int argc, char *argv[]) } else { while(fgets(buf, 1024, stdin)) { sscanf(buf, "%15s", pg); - snprintf(u, URLMAX, "/books?id=%s", bookid); - get("books.google.com", u, NULL, cookie, &tmp); + get("books.google.com", "/", NULL, cookie, &tmp); if(!(page = getpagedetail(bookid, pg, cookie)) || !page->url[0]) { fprintf(stderr, "%s failed\n", pg); if(page) free(page); -- cgit v1.2.3