Created
February 4, 2023 16:52
-
-
Save R3DHULK/b1a777016f56bb27d6153afb3b45d3f9 to your computer and use it in GitHub Desktop.
Web Scrapping In CPP
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 <iostream> | |
#include <curl/curl.h> | |
#include <string> | |
size_t write_data(char *ptr, size_t size, size_t nmemb, void *userdata) { | |
std::string html = (std::string)userdata; | |
html->append(ptr, size * nmemb); | |
return size * nmemb; | |
} | |
int main(void) { | |
CURL *curl; | |
CURLcode res; | |
std::string html; | |
curl = curl_easy_init(); | |
if (curl) { | |
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com"); | |
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); | |
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &html); | |
res = curl_easy_perform(curl); | |
curl_easy_cleanup(curl); | |
} | |
std::cout << html << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
help me
web-scrapper.cpp:2:10: fatal error: curl/curl.h: No such file or directory
2 | #include <curl/curl.h>
| ^~~~~~~~~~~~~
compilation terminated.