環境:Win7 64位+VC2008
軟件及源碼下載:(由於上傳的資源被刪除,需要的留下郵箱)
涉及到的知識點:
C++多線程編程
libcurl的使用(包括發送http請求、發送cookie給服務器、保存cookie)
關於libcurl的資料,推薦大家參考下官方文檔:http://curl.haxx.se/libcurl/c/example.html
curl_easy_duphandle
curl_easy_escape
curl_easy_getinfo
curl_easy_init
curl_easy_pause
curl_easy_perform
curl_easy_recv
curl_easy_reset
curl_easy_send
curl_easy_setopt
curl_easy_strerror
curl_easy_unescape
curl_escape (deprecated, do not use)
curl_formadd
curl_formfree
curl_formget
curl_free
curl_getdate
curl_getenv (deprecated, do not use)
curl_global_cleanup
curl_global_init
curl_global_init_mem
curl_mprintf (deprecated, do not use)
curl_multi_add_handle
curl_multi_assign
curl_multi_cleanup
curl_multi_fdset
curl_multi_info_read
curl_multi_init
curl_multi_perform
curl_multi_remove_handle
curl_multi_setopt
curl_multi_socket
curl_multi_socket_action
curl_multi_strerror
curl_multi_timeout
curl_share_cleanup
curl_share_init
curl_share_setopt
curl_share_strerror
curl_slist_append
curl_slist_free_all
curl_strequal (deprecated, do not use)
curl_strnequal (deprecated, do not use)
curl_unescape (deprecated, do not use)
curl_version
curl_version_info
char *curl_version( );
描述: 打印當前libcurl庫的版本 CURL *curl_easy_init( ); 描述:curl_easy_init用來初始化一個CURL的指針(有些像返回FILE類型的指針一樣). 相應的在調用結束時要用curl_easy_cleanup函數清理.
curl_easy_setopt(curl, CURLOPT_COOKIEJAR, );
讀取本地的cookie.txt文件中的cookie信息
curl_easy_setopt(easy_handle, CURLOPT_COOKIEFILE, "cookie.txt");
=* curl_slist *headers == curl_easy_setopt(curl, CURLOPT_COOKIEFILE, headers = curl_slist_append(headers,); headers = curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,); url[ res == curl_easy_setopt(curl, CURLOPT_WRITEDATA, & res =* pos = returnVal.find( ( pos >= = nStartPos = content.find( nEndPos = content.rfind(= content.substr(nStartPos+,nEndPos - nStartPos- nStartPos = returnVal.find( nEndPos = returnVal.find(= returnVal.substr(nStartPos+,nEndPos-nStartPos- =
GetHtmlPage(*= curl_easy_setopt(easy_handle, CURLOPT_COOKIEFILE,); curl_easy_setopt(easy_handle,CURLOPT_FOLLOWLOCATION, curl_slist *headers == curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,); (! *
url = html = nPos = html.rfind( (nPos == - --= nStartPos = html.rfind( strTotal = html.substr(nStartPos+,nPos - nStartPos -
vector<DownResourceInfo> GetToCommentList(<DownResourceInfo> url[] = { html = nPos = n = flag = ((nPos = html.find(,n)) != -= nPos+ nStartPos = html.rfind( strUrl = html.substr(nStartPos+,nPos - nStartPos -= nStartPos = html.find(strUrl,nPos+(nStartPos == -+= += nEndPos = html.find( ResourceName = html.substr(nStartPos,nEndPos -=
BOOL AddComment(*= curl_easy_setopt(easy_handle, CURLOPT_COOKIEFILE, url = +sourceId+ referer = + curl_slist *headers == curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,= curl_slist_append(headers,== curl_slist_append(headers,); (! pos = content.find( (pos>=