diff options
author | Nick White <hg@njw.me.uk> | 2011-07-16 12:55:44 +0100 |
---|---|---|
committer | Nick White <hg@njw.me.uk> | 2011-07-16 12:55:44 +0100 |
commit | 4c5740f8a747cc886d2b7bd807300818e3be22a9 (patch) | |
tree | 6fe36344bf4274b3bab7c823b9d5010ff6ba6681 | |
parent | 5f2172cc8ca50cea7d09b4a569f958a3015f33e7 (diff) |
Handle \u0026 as &
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | getgbook.c | 16 |
2 files changed, 13 insertions, 6 deletions
@@ -0,0 +1,3 @@ +use order to be able to use real page numbers (getpagecode) + +it appears cookies aren't actually needed. which is good @@ -58,8 +58,7 @@ char *getbookid(char *isbn) char *getpageurl(char *bookid, char *pg) { char url[URLMAX]; - int l; - char *buf, *c, *d, m[80], *pageurl; + char *buf, *c, *d, m[80], *pageurl, *p; snprintf(url, URLMAX, "/books?id=%s&pg=%s&jscmd=click3", bookid, pg); @@ -71,11 +70,16 @@ char *getpageurl(char *bookid, char *pg) return NULL; if(strncmp(c+strlen(m)+1, "\"src\"", 5) != 0) return NULL; - for(l=0, d=c+strlen(m)+8; *d && *d != '"'; *d++, l++); - pageurl = malloc(sizeof(char *) * l); - strncpy(pageurl, c+strlen(m)+8, l); - pageurl[l] = '\0'; + pageurl = malloc(sizeof(char *) * URLMAX); + for(p=pageurl, d=c+strlen(m)+8; *d && *d != '"'; *d++, *p++) { + if(!strncmp(d, "\\u0026", 6)) { + *p = '&'; + d+=5; + } else + *p = *d; + } + *p = '\0'; free(buf); return pageurl; |