Advertisement
metalx1000

g++ cURL Download webpage

Nov 10th, 2022
1,743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | Source Code | 0 0
  1. #include <stdio.h>
  2. #include <curl/curl.h>
  3. #define SIZE_OF_BUFF 100
  4.  
  5. //int main(void){
  6. int main(int argc, char *argv[]){
  7.   CURL *curl;
  8.   CURLcode res;
  9.  
  10.   if(argc < 2) {
  11.     printf("Usage: %s <URL>\n", argv[0]);
  12.     return 1;
  13.   }
  14.  
  15.   curl = curl_easy_init();
  16.   curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
  17.   //Follow redirect
  18.   curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  19.   res = curl_easy_perform(curl);
  20.  
  21.   /* always cleanup */
  22.   curl_easy_cleanup(curl);
  23.   return 0;
  24. }
  25.  
  26.  
  27.  
Tags: curl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement