Created
February 4, 2023 16:49
-
-
Save R3DHULK/5ca0765f1f960b3e30d2b3aa71f263da to your computer and use it in GitHub Desktop.
Web Scrapping In C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <curl/curl.h> | |
size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { | |
FILE *f = (FILE*)userdata; | |
return fwrite(ptr, size, nmemb, f); | |
} | |
int main(int argc, char **argv) { | |
CURL *curl = curl_easy_init(); | |
if (curl) { | |
FILE *f = fopen("output.txt", "w"); | |
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com"); | |
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); | |
curl_easy_setopt(curl, CURLOPT_WRITEDATA, f); | |
curl_easy_perform(curl); | |
curl_easy_cleanup(curl); | |
fclose(f); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
help me
web-scraper.c:3:10: fatal error: curl/curl.h: No such file or directory
3 | #include <curl/curl.h>
| ^~~~~~~~~~~~~
compilation terminated.