|
@@ -119,11 +119,9 @@ int images_handler(UrlParams *params) {
|
|
|
int first = (page - 1) * 32 + 1;
|
|
int first = (page - 1) * 32 + 1;
|
|
|
snprintf(url, sizeof(url),
|
|
snprintf(url, sizeof(url),
|
|
|
"https://www.bing.com/images/search?q=%s&first=%d", encoded_query, first);
|
|
"https://www.bing.com/images/search?q=%s&first=%d", encoded_query, first);
|
|
|
- fprintf(stderr, "[DEBUG] Fetching URL: %s\n", url);
|
|
|
|
|
|
|
|
|
|
char *html = fetch_images_html(url);
|
|
char *html = fetch_images_html(url);
|
|
|
if (!html) {
|
|
if (!html) {
|
|
|
- fprintf(stderr, "[DEBUG] Failed to fetch HTML\n");
|
|
|
|
|
send_response("<h1>Error fetching images</h1>");
|
|
send_response("<h1>Error fetching images</h1>");
|
|
|
free(encoded_query);
|
|
free(encoded_query);
|
|
|
free(display_query);
|
|
free(display_query);
|
|
@@ -161,7 +159,6 @@ int images_handler(UrlParams *params) {
|
|
|
|
|
|
|
|
if (xpathObj && xpathObj->nodesetval) {
|
|
if (xpathObj && xpathObj->nodesetval) {
|
|
|
int nodes = xpathObj->nodesetval->nodeNr;
|
|
int nodes = xpathObj->nodesetval->nodeNr;
|
|
|
- fprintf(stderr, "[DEBUG] Found %d image items\n", nodes);
|
|
|
|
|
|
|
|
|
|
int max_images = (nodes < 32) ? nodes : 32;
|
|
int max_images = (nodes < 32) ? nodes : 32;
|
|
|
image_matrix = malloc(sizeof(char **) * max_images);
|
|
image_matrix = malloc(sizeof(char **) * max_images);
|
|
@@ -233,12 +230,6 @@ int images_handler(UrlParams *params) {
|
|
|
xmlChar *title = des_node ? xmlNodeGetContent(des_node) : (tit_node ? xmlNodeGetContent(tit_node) : NULL);
|
|
xmlChar *title = des_node ? xmlNodeGetContent(des_node) : (tit_node ? xmlNodeGetContent(tit_node) : NULL);
|
|
|
xmlChar *rurl = tit_node ? xmlGetProp(tit_node, (const xmlChar *)"href") : NULL;
|
|
xmlChar *rurl = tit_node ? xmlGetProp(tit_node, (const xmlChar *)"href") : NULL;
|
|
|
|
|
|
|
|
- fprintf(stderr, "[DEBUG] Image %d: thumb=%s, full=%s, title=%s, site=%s\n",
|
|
|
|
|
- image_count, iurl ? (char *)iurl : "nil",
|
|
|
|
|
- full_url ? (char *)full_url : "nil",
|
|
|
|
|
- title ? (char *)title : "nil",
|
|
|
|
|
- rurl ? (char *)rurl : "nil");
|
|
|
|
|
-
|
|
|
|
|
if (iurl && strlen((char *)iurl) > 0) {
|
|
if (iurl && strlen((char *)iurl) > 0) {
|
|
|
image_matrix[image_count] = malloc(sizeof(char *) * 4);
|
|
image_matrix[image_count] = malloc(sizeof(char *) * 4);
|
|
|
image_matrix[image_count][0] = strdup((char *)iurl);
|
|
image_matrix[image_count][0] = strdup((char *)iurl);
|