diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..32ad2c6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+#忽略这些依赖的库文件可以到
+#发布页面下载https://github.com/cool2528/baiduCDP/releases
+/.vs
+/include
+/lib
+/LocalStorage
+
+#防止编译器生成的文件也上传
+/Debug
+/Release
+#这些都是vs项目生成的文件
+*.aps
+*.suo
+*.db
+*.dll
+*.lib
+*.sdf
+*.db
+*.iobj
+*.ipdb
+*.ipch
+*.1.tlog
+*.log
+*.pch
+*.pdb
\ No newline at end of file
diff --git a/BaiduCdp.rc b/BaiduCdp.rc
new file mode 100644
index 0000000..19ebd1d
Binary files /dev/null and b/BaiduCdp.rc differ
diff --git a/BaiduCdp.sln b/BaiduCdp.sln
new file mode 100644
index 0000000..9676ed1
--- /dev/null
+++ b/BaiduCdp.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaiduCdp", "BaiduCdp.vcxproj", "{34066ECC-24F2-4940-BB0B-1A119ACF43FE}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {34066ECC-24F2-4940-BB0B-1A119ACF43FE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {34066ECC-24F2-4940-BB0B-1A119ACF43FE}.Debug|Win32.Build.0 = Debug|Win32
+ {34066ECC-24F2-4940-BB0B-1A119ACF43FE}.Release|Win32.ActiveCfg = Release|Win32
+ {34066ECC-24F2-4940-BB0B-1A119ACF43FE}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/BaiduCdp.vcxproj b/BaiduCdp.vcxproj
new file mode 100644
index 0000000..3983d4c
--- /dev/null
+++ b/BaiduCdp.vcxproj
@@ -0,0 +1,105 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {34066ECC-24F2-4940-BB0B-1A119ACF43FE}
+ Win32Proj
+ BaiduCdp
+
+
+
+ Application
+ true
+ v140_xp
+ Unicode
+
+
+ Application
+ false
+ v120
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;CURL_STATICLIB;D_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ false
+ e:\boost_1_67_0;.\include;%(AdditionalIncludeDirectories)
+ MultiThreadedDebug
+
+
+ Windows
+ true
+ E:\boost_1_67_0\lib32-msvc-14.0;.\lib
+ ws2_32.lib;wldap32.lib;Crypt32.lib;%(AdditionalDependencies)
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ true
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BaiduCdp.vcxproj.filters b/BaiduCdp.vcxproj.filters
new file mode 100644
index 0000000..83c54eb
--- /dev/null
+++ b/BaiduCdp.vcxproj.filters
@@ -0,0 +1,62 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+ {e8fec2f2-1e54-4228-a65b-4d83b388d88d}
+
+
+
+
+ 源文件
+
+
+ 源文件
+
+
+ BaiduParse
+
+
+ BaiduParse
+
+
+
+
+ 头文件
+
+
+ 头文件
+
+
+ 头文件
+
+
+ BaiduParse
+
+
+ BaiduParse
+
+
+ BaiduParse
+
+
+ 头文件
+
+
+
+
+ 资源文件
+
+
+
\ No newline at end of file
diff --git a/GlobalHeader.h b/GlobalHeader.h
new file mode 100644
index 0000000..42cd546
--- /dev/null
+++ b/GlobalHeader.h
@@ -0,0 +1,18 @@
+#ifndef __GLOBALHEADER__
+#define __GLOBALHEADER__
+#include "wke.h"
+#include
+#include
+#include
+typedef struct {
+ wkeWebView window;
+ std::wstring url;
+} Application;
+#define MBDLL_NAME L"node.dll"
+#define APP_NAME L"BaiduCdp"
+#define CLOSE_MSG "close"
+#define MAX_MSG "max"
+#define MIN_MSG "min"
+#define HOST_NAME "http://baiducdp.com"
+extern Application app;
+#endif
diff --git a/Http_Request.cpp b/Http_Request.cpp
new file mode 100644
index 0000000..ac1614c
--- /dev/null
+++ b/Http_Request.cpp
@@ -0,0 +1,336 @@
+#include "Http_Request.h"
+#include
+#include
+#ifdef _DEBUG
+#pragma comment(lib,"libcurld.lib")
+#else
+#pragma comment(lib,"libcurl.lib")
+#endif
+HttpRequest::HttpRequest()
+:m_CurlHandle(NULL),
+headerList(nullptr),
+m_Cookies("")
+{
+ try{
+ CURLcode rcode = curl_global_init(CURL_GLOBAL_ALL);
+ if (rcode)
+ throw rcode;
+ m_CurlHandle = curl_easy_init();
+ if (m_CurlHandle)
+ {
+ curl_easy_setopt(m_CurlHandle, CURLOPT_SSL_VERIFYPEER, false); // ֤ԷSSL֤
+ curl_easy_setopt(m_CurlHandle, CURLOPT_SSL_VERIFYHOST, false); //֤֤
+ }
+ }
+ catch (CURLcode& errCode)
+ {
+ //־
+ throw std::runtime_error("LibCurl initialization environment failed");
+ }
+}
+
+HttpRequest::~HttpRequest()
+{
+ if (headerList)
+ {
+ curl_slist_free_all(headerList);
+ headerList = nullptr;
+ }
+ if (m_CurlHandle)
+ {
+ curl_easy_cleanup(m_CurlHandle);
+ m_CurlHandle = nullptr;
+ }
+ curl_global_cleanup(); //رcurl
+}
+
+void HttpRequest::SetRequestHeader(const std::string strKey, const std::string strValue)
+{
+ std::string strRequestHeader(strKey + ":" + strValue);
+ headerList = curl_slist_append(headerList, strRequestHeader.c_str());
+}
+
+void HttpRequest::SetRequestHeader(RequestHeaderValue& HeaderValue)
+{
+ for (auto &v : HeaderValue)
+ {
+ std::string strRequestHeader(v.first + ":" + v.second);
+ headerList = curl_slist_append(headerList, strRequestHeader.c_str());
+ }
+}
+
+void HttpRequest::Send(RequestType Enumtype, const std::string strUrl,const std::string strPost)
+{
+ CURLcode dwCurlCode;
+ if (!m_CurlHandle)return;
+ m_Request.clear();
+ m_ResponseHeader.clear();
+ m_Cookies.clear();
+ switch (Enumtype)
+ {
+ case GET:
+ {
+ AutoAddHeader();
+ if (!CheckHeaderExist("Referer:"))
+ {
+ headerList = curl_slist_append(headerList, ("Referer:" + strUrl).c_str());
+ }
+ //URL
+ curl_easy_setopt(m_CurlHandle, CURLOPT_URL, strUrl.c_str());
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HTTPHEADER, headerList); //ԶЭͷͷ
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HEADERFUNCTION, header_callback); //ûصЭͷ
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HEADERDATA, &m_ResponseHeader);
+ curl_easy_setopt(m_CurlHandle, CURLOPT_WRITEFUNCTION, read_callback); //дĻص
+ curl_easy_setopt(m_CurlHandle, CURLOPT_WRITEDATA, &m_Request); //շص
+ curl_easy_setopt(m_CurlHandle, CURLOPT_NOBODY, 0); //շص
+ dwCurlCode = curl_easy_perform(m_CurlHandle);
+ if (CURLE_OK != dwCurlCode)
+ {
+ //־
+ }
+ m_Cookies = GetCookies(GetallResponseHeaders());
+
+ }
+ break;
+ case POST:
+ {
+ AutoAddHeader();
+ if (!CheckHeaderExist("Referer:"))
+ {
+ headerList = curl_slist_append(headerList, ("Referer:" + strUrl).c_str());
+ }
+ if (!CheckHeaderExist("Content-Type:"))
+ {
+ headerList = curl_slist_append(headerList, ("Content-Type: application/x-www-form-urlencoded"));
+ }
+ //URL
+ curl_easy_setopt(m_CurlHandle, CURLOPT_URL, strUrl.c_str());
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HTTPHEADER, headerList); //ԶЭͷͷ
+ curl_easy_setopt(m_CurlHandle, CURLOPT_POSTFIELDSIZE, (long)strPost.length()); //Ҫ͵ݴС
+ curl_easy_setopt(m_CurlHandle, CURLOPT_POSTFIELDS, strPost.c_str()); //Ҫ͵
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HEADERFUNCTION, header_callback); //ûصЭͷ
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HEADERDATA, &m_ResponseHeader);
+ curl_easy_setopt(m_CurlHandle, CURLOPT_WRITEFUNCTION, read_callback); //дĻص
+ curl_easy_setopt(m_CurlHandle, CURLOPT_WRITEDATA, &m_Request); //շص
+ curl_easy_setopt(m_CurlHandle, CURLOPT_NOBODY, 0); //շص
+ dwCurlCode = curl_easy_perform(m_CurlHandle);
+ if (CURLE_OK != dwCurlCode)
+ {
+ //־
+ }
+ m_Cookies = GetCookies(GetallResponseHeaders());
+ }
+ break;
+ case HEAD:
+ {
+ AutoAddHeader();
+ if (!CheckHeaderExist("Referer:"))
+ {
+ headerList = curl_slist_append(headerList, ("Referer:" + strUrl).c_str());
+ }
+ //URL
+ curl_easy_setopt(m_CurlHandle, CURLOPT_URL, strUrl.c_str());
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HTTPHEADER, headerList); //ԶЭͷͷ
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HEADERFUNCTION, header_callback); //ûصЭͷ
+ curl_easy_setopt(m_CurlHandle, CURLOPT_HEADERDATA, &m_ResponseHeader);
+ curl_easy_setopt(m_CurlHandle, CURLOPT_WRITEFUNCTION, read_callback); //дĻص
+ curl_easy_setopt(m_CurlHandle, CURLOPT_WRITEDATA, &m_Request); //շص
+ curl_easy_setopt(m_CurlHandle, CURLOPT_NOBODY, 1); //շص
+ dwCurlCode = curl_easy_perform(m_CurlHandle);
+ if (CURLE_OK != dwCurlCode)
+ {
+ //־
+ }
+ m_Cookies = GetCookies(GetallResponseHeaders());
+ }
+ default:
+ break;
+ }
+ if (headerList)
+ {
+ curl_slist_free_all(headerList);
+ headerList = nullptr;
+ }
+}
+
+std::string HttpRequest::GetResponseText()
+{
+ std::string strResultText;
+ for (auto v: m_Request)
+ strResultText.append(1, v);
+ return strResultText;
+}
+
+responseData HttpRequest::GetResponseBody() const
+{
+ return m_Request;
+}
+
+std::string HttpRequest::GetallResponseHeaders()
+{
+ std::string strResultText;
+ for (auto v : m_ResponseHeader)
+ strResultText.append(1, v);
+ return strResultText;
+}
+
+void HttpRequest::SetRequestCookies(const std::string strCookie)
+{
+ if (!m_CurlHandle)return;
+ curl_easy_setopt(m_CurlHandle, CURLOPT_COOKIE, strCookie.c_str());
+
+}
+
+void HttpRequest::SetHttpRedirect(bool val)
+{
+ if (!m_CurlHandle)return;
+ curl_easy_setopt(m_CurlHandle, CURLOPT_FOLLOWLOCATION, (long)val);
+}
+
+std::string HttpRequest::GetResponCookie() const
+{
+ return m_Cookies;
+}
+
+void HttpRequest::AutoAddHeader()
+{
+ if (!headerList || !CheckHeaderExist("Accept:"))
+ {
+ headerList = curl_slist_append(headerList, "Accept:*/*");
+ }
+ if (!CheckHeaderExist("Accept-Language:"))
+ {
+ headerList = curl_slist_append(headerList, "Accept-Language:zh-cn");
+ }
+ if (!CheckHeaderExist("User-Agent:"))
+ {
+ headerList = curl_slist_append(headerList, "User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
+ }
+}
+
+std::string HttpRequest::GetCookies(const std::string strHeader)
+{
+ std::string strResult, strTwoResult;
+ std::vector headerList;
+ std::set resultList;
+ if (!strHeader.empty())
+ {
+ std::string split = strHeader + "\r\n";
+ std::string strsub;
+ size_t pos = 0;
+ size_t npos = 0;
+ npos = split.find("\r\n", pos);
+ while (npos != std::string::npos)
+ {
+ strsub = split.substr(pos, npos - pos);
+ pos = npos + strlen("\r\n");
+ npos = split.find("\r\n", pos);
+ headerList.push_back(strsub);
+ }
+ }
+ for (auto & v : headerList)
+ {
+ std::string strTmp;
+ int nPos = v.find("Set-Cookie:");
+ if (nPos != std::string::npos)
+ {
+ std::string strTmp = v.substr(nPos + lstrlenA("Set-Cookie:"), v.length() - (nPos + lstrlenA("Set-Cookie:")));;
+ if (strTmp.at(strTmp.length() - 1) != ';')
+ {
+ strTmp += ";";
+ }
+ strResult += strTmp;
+ }
+ }
+ headerList.clear();
+ if (!strResult.empty())
+ {
+ if (strResult.at(strResult.length() - 1) != ';')
+ strResult += ";";
+ std::string split = strResult;
+ std::string strsub;
+ size_t pos = 0;
+ size_t npos = 0;
+ npos = split.find(";", pos);
+ while (npos != std::string::npos)
+ {
+ strsub = split.substr(pos, npos - pos);
+ pos = npos + strlen(";");
+ npos = split.find(";", pos);
+ resultList.insert(strsub);
+ }
+ }
+ else
+ {
+ return strResult;
+ }
+
+ for (auto& s : resultList)
+ strTwoResult += s + ";";
+ return strTwoResult;
+}
+
+std::vector HttpRequest::StrSplit(const std::string &str, const std::string &pattern)
+{
+ std::vector resultVec;
+ std::string split = str;
+ std::string strsub;
+ size_t pos = 0;
+ size_t npos = 0;
+ npos = split.find(pattern, pos);
+ while (npos != std::string::npos)
+ {
+ strsub = split.substr(pos, npos - pos);
+ pos = npos + pattern.length();
+ npos = split.find(pattern, pos);
+ resultVec.push_back(strsub);
+ }
+ return resultVec;
+}
+
+std::string HttpRequest::MergeCookie(const std::string wornCookie, const std::string newCookie)
+{
+ std::string strResult = wornCookie;
+ std::vector strCookieArr = StrSplit(newCookie, ";");
+ for (auto v : strCookieArr)
+ {
+ int npos = std::string::npos;
+ if (strResult.find(v) == npos)
+ strResult += v + ";";
+ }
+ return strResult;
+}
+
+bool HttpRequest::CheckHeaderExist(const std::string strHeaderKey)
+{
+ bool isBresult = false;
+ struct curl_slist* TmpheaderList = headerList;
+ while (TmpheaderList)
+ {
+ std::string tmpHeaderstr = TmpheaderList->data;
+ if (tmpHeaderstr.find(strHeaderKey)!=std::string::npos)
+ {
+ isBresult = true;
+ break;
+ }
+ TmpheaderList = TmpheaderList->next;
+ }
+ return isBresult;
+}
+
+size_t HttpRequest::header_callback(char *ptr, size_t size, size_t nmemb, void* userdata)
+{
+ size_t lsize = size * nmemb;
+ for (size_t i = 0; i < lsize; i++)
+ ((responseData*)userdata)->push_back(ptr[i]);
+ return lsize;
+}
+
+size_t HttpRequest::read_callback(char *ptr, size_t size, size_t nmemb, void* userdata)
+{
+ size_t lsize = size * nmemb;
+ for (size_t i = 0; i < lsize; i++)
+ ((responseData*)userdata)->push_back(ptr[i]);
+ return lsize;
+}
+
diff --git a/Http_Request.h b/Http_Request.h
new file mode 100644
index 0000000..2a2abed
--- /dev/null
+++ b/Http_Request.h
@@ -0,0 +1,119 @@
+#ifndef __HTTP_REQUEST__
+#define __HTTP_REQUEST__
+#include
+#include
+#include
+#include