A
A
Arcanis2017-07-23 14:13:09
RSS
Arcanis, 2017-07-23 14:13:09

Why does the site become inaccessible after downloading rss from habrahabr.ru using libcurl?

Hello, I use the following code to upload an rss file from https://habrahabr.ru/rss/best/ :

//взято с https://curl.haxx.se/libcurl/c/url2file.html
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
  size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
  return written;
}
 
void load_rss()
{
  CURL *curl_handle;
  static const char *pagefilename = "habrahabr.rss";
  FILE *pagefile;
  
  curl_global_init(CURL_GLOBAL_ALL);
 
  curl_handle = curl_easy_init();
  curl_easy_setopt(curl_handle, CURLOPT_URL, "https://habrahabr.ru/rss/best/");
  curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
  curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
 
  pagefile = fopen(pagefilename, "wb");
  if(pagefile) {
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile);
    curl_easy_perform(curl_handle);
    fclose(pagefile);
  }
  curl_easy_cleanup(curl_handle);
}

After the program is executed, the file is written successfully, but the site ceases to be available (does not open in the browser) for 4-5 hours. What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question