Question:
Hello, my console returns an error `curl/curl.h that states no such file or directory exists. Do I need to download the libraries as I do not have permission to access root (obv)? This is a school final project so I want to ensure I am do this correctly.
Repl link:
(https://replit.com/@nateASC4/WebCrawler)
#include <stdio.h> // scanning through files
#include <string.h> // scanning through files
#include <curl/curl.h> // to send HTTP requests
#include <libxml/HTMLparser.h> // for parsing HTML and XML
#include <pthread.h> ///for POSIX multithreading
#include <stdlib.h> // scanning through files
#define NUM_THREADS 6
#define MAX_LINKS 10
//max URL length
#define MAX_URL_LENGTH 2083
#define buffer[MAX_URL_LENGTH]
//In this program we will follow SOLID principles to ensure clarity and improve functionality of our code
//scan a file for URL
// Check if filename is provided as an argument
int step1_scanFile(){
int scan = 0;
if (scan != 2) {
printf("Usage: ./scan_urls <filename>\n");
return 1;
}
// Open file
FILE* fp = fopen("url.txt", "r");
if (fp == NULL) {
printf("Error: could not open file %s\n", "url.txt");
return 1;
}
//we need to iterate through the list in a loop
char url[MAX_URL_LENGTH];
while (fgets(url, MAX_URL_LENGTH, fp) != NULL) {
// Remove trailing newline character if present
if (url[strlen(url) - 1] == '\n') {
url[strlen(url) - 1] = '\0';
}
// Check if url starts with http:// or https://
if (strncmp(url, "http://", 7) == 0 || strncmp(url, "https://", 8) == 0) {
//use strncmp to avoid buffer overflows
printf("Found URL: %s\n", url);
}
//if url does not exist
else {
printf("%s","404:URL not FOUND");
}
}
// Close file
fclose(fp);
return 0;
}
//initialize the libcurl library
void step0_initlibcurl(){
CURL* curler;
Curlcode res;
res = curl_easy_perform(curl);
// Check if the curl request was successful
if (res != CURLE_OK) {
printf("Error performing curl request: %s\n", curl_easy_strerror(res));
return 1;```