读书人

curl取得cookie数据

发布时间: 2013-03-21 10:08:17 作者: rapoo

curl获得cookie数据

研究了一下curl操作cookie的方法,有个需要注意的地方:

curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/");    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);    curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); /* just to start the cookie engine */     res = curl_easy_perform(curl);    if (res != CURLE_OK) {      fprintf(stderr, "Curl perform failed: %s\n", curl_easy_strerror(res));      return 1;    }     print_cookies(curl);
CURLOPT_COOKIEFILE后有一句注释just to start the cookie engine.译为"仅仅开始cookie引擎",你运行cookie引擎用个别的方法好不好?否则从CURLOPT_COOKIEFILE上理解就是与cookie的file有关系,太有歧义了.

所以,通过curl获得cookie一定要注意这里.



读书人网 >互联网

热点推荐