亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? crobotinternet.cpp

?? Visual C++自動查詢和智能代理程序設(shè)計書籍源碼-AnyQuote
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
// *                      *
// ************************
// Function: Returns the value for the specified header field.
//			 Call httpHeaderFields before calling this function.
//
// Inputs:	 sFieldName		  - The header field name desired 
//								 (example: "Last-modified").
//			 m_sHeader		  - Set from previous call to 
//								 httpHeaderFields
//			 m_nHeaderFields  - Set from previous call to 
//                               httpHeaderFields
//			 m_sHeaderName[]  - Set from previous call to
//								 httpHeaderFields
//			 m_sHeaderValue[] - Set from previous call to
//								 httpHeaderFields
//
// Outputs:	<function_result> - True if header field was found
//			sValue            - Value for the field

BOOL CRobotInternet::httpGetHeaderField(const CString& sName,
										CString& sValue)
{
	CString sTemp1;
	CString sTemp2;
	sValue = "";
	sTemp1 = sName;
	sTemp1.MakeLower();
	if (sTemp1.Right(1) == ":")
		sTemp1 = sTemp1.Left(sTemp1.GetLength() - 1);
	
	for (int n = 0; n < m_nHeaderFields; n++)
	{
		sTemp2 = m_sHeadName[n];
		sTemp2.MakeLower();
		if (sTemp1 == sTemp2)
		{
			sValue = m_sHeadValue[n];
			n = m_nHeaderFields;
			return true;
			} // End if
	} // End for
	return false;
}


// --------------------------------------------------------------
// ************** public
// *            *
// *  httpPost  *
// *            *
// **************
// Function: Submits a URL and form data/parameters using the POST
//           method. Retrieves a response returns it in CString form.
//
// Inputs:	sURL              - The URL to access
//								 (example: "www.mysite.com")
//			sData			  - The parameters (or "form data")
//								 to submit
//
// Outputs:	<function_result> - True if data was successfully
//								 retrieved, false otherwise
//			sResponse         - The HTML retrieved
//			nResult           - Completion code. 0 = success,
//								 n = error (defined in CRobot.h)
//			sErrMsg           - The error message, if nResult != 0

BOOL CRobotInternet::httpPost(const CString& sUrl,
							  const CString& sData,
							  CString& sResponse,
							  int& nResult, CString& sErrMsg)
{
	CInternetSession* pSession;
	CHttpConnection* pConnection;
	CHttpFile* pHttpFile;
	int nRead;
	LPSTR pBuffer = NULL;
	CString sResult;
	CString sWorkingUrl;
	CString sHeaders = "";
	CString sMsg;
	sErrMsg = "";
	DWORD dwHttpStatus;
	nResult = CROBOT_ERR_SUCCESS;
	TCHAR sTemp[1024];

	try 
	{
		pSession = NULL;
		pConnection = NULL;
		pHttpFile = NULL;
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sUrl;
		sHeaders = _T("Content-Type: "
					  "application/x-www-form-urlencoded\r\n")
				   + CreateStandardHeader();

		/* Trim URL and add http:// if it contains no 
		   protocol identifier */
		
		sWorkingUrl.TrimLeft();
		sWorkingUrl.TrimRight();
		if (sWorkingUrl.Find(":") == -1) 
		{
			if (sWorkingUrl.Left(1) == "/")
				sWorkingUrl = "http:" + sWorkingUrl;
			else
				sWorkingUrl = "http://" + sWorkingUrl;
		} // End if

		/* Check the URL - must be valid and of the 'http:'
		   service type */
		DWORD dwServiceType;
		CString sServer, sObject;
		unsigned short nPort;
		if (AfxParseURL(sWorkingUrl,
						dwServiceType,
						sServer,
						sObject,
						nPort))
		{
			// URL is valid. Now check service type.
			if (dwServiceType == AFX_INET_SERVICE_HTTP) 
			{
				// Service type is valid (HTTP). Now make connection.
				pSession = new CInternetSession(
										m_sUserAgent,
										1,
										INTERNET_OPEN_TYPE_PRECONFIG);
				pConnection = pSession->GetHttpConnection(sServer,
														  nPort,
														  NULL,
														  NULL);

				pHttpFile = pConnection->OpenRequest(
										CHttpConnection::HTTP_VERB_POST,
										sObject,
										sServer,
										1,
										NULL,
										NULL,
										INTERNET_FLAG_EXISTING_CONNECT
											| INTERNET_FLAG_RELOAD
											| INTERNET_FLAG_DONT_CACHE);
				strcpy (sTemp, sData);
				pHttpFile->SendRequest(sHeaders,
									   sTemp,
									   sData.GetLength());
				if (pHttpFile) /* SendRequest worked */
				{
					// Check the http return code
					if (!pHttpFile->QueryInfoStatusCode(dwHttpStatus))
						dwHttpStatus = 200;

					if (dwHttpStatus >= 400)
					{
						switch(dwHttpStatus)
						{
						case 404:
							nResult = CROBOT_ERR_NOT_FOUND;
							break;
						case 403:
						case 407:
							nResult = CROBOT_ERR_NOT_AUTHORIZED;
							break;
						default:
							nResult = CROBOT_ERR_CONNECTION_FAILED;
							break;
						} // End switch
					} // End if dwHttpStatus
					else /* No error - read response data */
					{
						nResult = CROBOT_ERR_SUCCESS;
						do 
						{
							nRead = pHttpFile->Read(pBuffer, 1023);
							if (nRead != 0) 
							{
								pBuffer[nRead] = 0;
								sResult += pBuffer;
							} // End if
						} while (nRead != 0);
						sResponse = sResult;
					} // End else
				} // End if pHttpFile
				else /* SendRequest failed */
				{
					nResult = CROBOT_ERR_CONNECTION_FAILED;
				} // End else
			} // End if
			else
				// Wrong service
				nResult = CROBOT_ERR_INVALID_URL;
		} // End if
		else
			// Invalid URL
			nResult = CROBOT_ERR_INVALID_URL;
	} // End try

	catch (CInternetException* e) 
	{
		e->Delete();
		sResponse = sResult;
		
		// Exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch
	catch (...) 
	{
		sResponse = sResult;
		
		// Exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

// Clean up and exit function

	if (pBuffer != NULL)
	{
		delete pBuffer;
		pBuffer = NULL;
	} // End if
	
	if (pHttpFile != NULL) 
	{
		pHttpFile->Close();
		delete pHttpFile; 
	} // End if

	if (pConnection != NULL) 
	{
		pConnection->Close();
		delete pConnection; 
	} // End if

	if (pSession != NULL) 
	{
		pSession->Close();
		delete pSession; 
	} // End if
	
	sErrMsg = ErrorMessage(nResult);
	if (nResult == CROBOT_ERR_SUCCESS)
		return true;
	else
		return false;
}


// --------------------------------------------------------------
// ****************** public
// *                *
// *  httpPostFile  *
// *                *
// ******************
// Function: Submits a URL and form data/parameters using
//           the POST method. Retrieves response and outputs
//           it to a file.
//
// Inputs:	sURL              - The URL to access
//								 (example: "www.mysite.com")
//			sData			  - The parameters (or "form data")
//								 to submit
//			sOutputFilespec   - File specification of file to 
//								 create/overwrite
//
// Outputs:	<function_result> - True if data was successfully
//								 retrieved, false otherwise
//			nResult           - Completion code. 0 = success,
//								 n = error (defined in CRobot.h)
//			sErrMsg           - The error message, if nResult != 0

BOOL CRobotInternet::httpPostFile(const CString& sUrl,
								  const CString& sData,
								  const CString& sOutputFilespec,
								  int& nResult,
								  CString& sErrMsg)
{
	CInternetSession* pSession;
	CHttpConnection* pConnection;
	CHttpFile* pHttpFile;
	CString sHeader;
	int nRead;
	LPSTR pBuffer = NULL;
	CString sResult;
	CString sWorkingUrl;
	CString sHeaders = "";
	CFile* pLocalFile;
	char sTemp[1024];
	DWORD dwHttpStatus;
	nResult = CROBOT_ERR_SUCCESS;
	CString sMsg;

	try 
	{
   		pSession = NULL;
		pConnection = NULL;
		pHttpFile = NULL;
		pLocalFile = NULL;
		sHeader = CreateStandardHeader();
		nRead = 0;
		pBuffer = new char[1024];
		sResult = "";
		sWorkingUrl = sUrl;
		sHeaders = _T("Content-Type: "
					  "application/x-www-form-urlencoded\r\n")
				   + CreateStandardHeader();

		/* Trim URL and add http:// if it contains no 
		   protocol identifier */
		
		sWorkingUrl.TrimLeft();
		sWorkingUrl.TrimRight();
		if (sWorkingUrl.Find(":") == -1) 
		{
			if (sWorkingUrl.Left(1) == "/")
				sWorkingUrl = "http:" + sWorkingUrl;
			else
				sWorkingUrl = "http://" + sWorkingUrl;
		} // End if

		/* Check the URL - must be valid and of the 'http:'
		   service type */
		DWORD dwServiceType;
		CString sServer, sObject;
		unsigned short nPort;
		if (AfxParseURL(sWorkingUrl,
						dwServiceType,
						sServer,
						sObject,
						nPort)) 
		{
			// URL is valid. Now check service type.
			if (dwServiceType == AFX_INET_SERVICE_HTTP)
			{
				/* Service type is correct (HTTP). 
				   Now make the connection. */
				pSession = new CInternetSession(
										m_sUserAgent,
										1,
										INTERNET_OPEN_TYPE_PRECONFIG);
				pConnection = pSession->GetHttpConnection(sServer,
														  nPort,
														  NULL,
														  NULL);
				
				pHttpFile = pConnection->OpenRequest(
									CHttpConnection::HTTP_VERB_POST,
									sObject,
									NULL,
									1,
									NULL,
									NULL,
									INTERNET_FLAG_EXISTING_CONNECT
										| INTERNET_FLAG_RELOAD
										| INTERNET_FLAG_DONT_CACHE);

				strcpy (sTemp, sData);
				pHttpFile->SendRequest(sHeaders,
									   &sTemp,
									   sData.GetLength());
				if (pHttpFile) /* SendRequest worked */
				{
					// Check the http return code
					if (!pHttpFile->QueryInfoStatusCode(dwHttpStatus))
						dwHttpStatus = 200;

					if (dwHttpStatus >= 400)
					{
						switch(dwHttpStatus)
						{
						case 404:
							nResult = CROBOT_ERR_NOT_FOUND;
							break;
						case 403:
						case 407:
							nResult = CROBOT_ERR_NOT_AUTHORIZED;
							break;
						default:
							nResult = CROBOT_ERR_CONNECTION_FAILED;
							break;
						} // End switch
					} // End if dwHttpStatus
					else /* No error - read response data */
					{
						nResult = CROBOT_ERR_SUCCESS;
						// Open local file for output
						pLocalFile = new CFile;

						pLocalFile->Open(sOutputFilespec,
										 CFile::modeWrite 
											| CFile::modeCreate);

						do 
						{
							nRead = pHttpFile->Read(pBuffer, 1023);
							if (nRead != 0)
							{
								pBuffer[nRead] = 0;
								pLocalFile->Write(pBuffer, nRead);
							} // End if
						} while (nRead != 0);
					} // End else
				} // End if pHttpFile
				else /* SendRequest failed */
				{
					nResult = CROBOT_ERR_CONNECTION_FAILED;
				}
			} // End if
			else
				// Wrong service
				nResult = CROBOT_ERR_CONNECTION_FAILED;
		} // End if
		else
			// Invalid URL
			nResult = CROBOT_ERR_INVALID_URL;
	} // End try

	catch (CInternetException* e) 
	{
		e->Delete();
		
		// Internet exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

	catch (...) 
	{
		// Exception occurred
		nResult = CROBOT_ERR_CONNECTION_FAILED;
	} // End catch

// Clean up and exit function
	
	if (pBuffer != NULL) 
	{
		delete pBuffer; 
		pBuffer = NULL;
	} // End if

	if (pHttpFile != NULL) 
	{
		pHttpFile->Close();
		delete pHttpFile; 
	} // End if
	
	if (pLocalFile != NULL) 
	{
		pLocalFile->Close();
		delete pLocalFile; 
	} // End if

	if (pConnection != NULL) 
	{
		pConnection->Close();
		delete pConnection; 
	} // End if
	
	if (pSession != NULL) 
	{
		pSession->Close();
		delete pSession;
	}  // End if

	sErrMsg = ErrorMessage(nResult);
	if (nResult == CROBOT_ERR_SUCCESS)
		return true;
	else
		return false;
}



// --------------------------------------------------------------
// *************** public
// *             *
// *  httpError  *
// *             *
// ***************
// Function: Scans an HTML response page for HTTP error codes.
//
// Inputs:	sHTML             - HTML response of a prior Internet
//								 access
//
// Outputs:	<function_result> - True if an error code was detected;
//								 false if no errors were detected in
//								 the response
//			nErrorCode        - HTTP error code, such as 404
//			sErrMsg           - Error message text for nErrorCode,
//								 such as "object not found"

BOOL CRobotInternet::httpError(const CString& sHTML,
							   int& nErrorCode,
							   CString& sErrMsg)
{
	CString sTemp = sHTML;
	int nPos;

	nPos = sTemp.Find("HTTP/1.0 ");
	if (nPos != -1)
		sTemp = sTemp.Mid(nPos + 9, 3);

	if (nPos == -1) 
	{
		nPos = sTemp.Find("HTTP Error ");
		if (nPos != -1)
			sTemp = sTemp.Mid(nPos + 11, 3);
	} // End if

	if (nPos != -1) 
	{
		nErrorCode = atoi(sTemp);
		sErrMsg = ResponseMessage(nErrorCode);
		return true;
	} // End if
	else 
	{
		nErrorCode = 0;
		sErrMsg = "";
		return false;
	} // End else
}


// --------------------------------------------------------------
// ************************ public
// *                      *
// *  ParseServerFromURL  *
// *                      *
// ************************
// Function: Scans a URL and returns the server name portion
//           of the URL
//
// Inputs:	sURL              - A fully qualified URL
//
// Outputs:	<function_result> - The server portion of the URL

CString CRobotInternet::ParseServerFromURL(const CString& sURL)
{
	DWORD dwService;
	INTERNET_PORT nPort;
	CString sServer;
	CString sObject;
	CString sPath;
	CString sTempURL;

	sTempURL = sURL;

	if (sTempURL.Find(":") == -1) 
	{
		if (sTempURL.Left(1) != "/")
			sTempURL = "//" + sTempURL;
		sTempURL = "http:" + sTempURL;
	} // End if

	AfxParseURL(sTempURL,
				dwService,
				sServer,
				sObject,
				nPort);

	return sServer;
}


// --------------------------------------------------------------
// ********************** public
// *                    *
// *  ParsePathFromURL  *
// *                    *
// **********************
// Function: Scans a URL and returns the directory path portion of
//           the URL.
//
// Inputs:	sURL              - a fully qualified URL.
//
// Outputs:	<function_result> - the directory path portion of the URL.

CString CRobotInternet::ParsePathFromURL(const CString& sURL)
{
	DWORD dwService;
	INTERNET_PORT nPort;
	CString sServer;
	CString sObject;
	CString sPath;
	int nPos;
	CString sTempURL;

	sTempURL = sURL;

	if (sTempURL.Find(":") == -1) 
	{
		if (sTempURL.Left(1) != "/")
			sTempURL = "//" + sTempURL;
		sTempURL = "http:" + sTempURL;
	} // End if

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美日韩系列| 欧美四级电影在线观看| 奇米精品一区二区三区在线观看 | 欧美久久久久久蜜桃| 欧美一区二区视频在线观看2020| www一区二区| 91精品福利视频| 国产欧美日韩麻豆91| 91精品国产一区二区人妖| 婷婷亚洲久悠悠色悠在线播放| 久久99精品久久久久久| 99久久国产综合色|国产精品| 欧美一a一片一级一片| 亚洲777理论| 91视频精品在这里| 欧美激情中文不卡| 麻豆精品久久精品色综合| 欧美日韩另类一区| 亚洲乱码国产乱码精品精可以看| 国产一区999| 欧美一区二区三区四区在线观看| 久久精品99国产精品日本| 欧美丰满少妇xxxbbb| 国产精品69久久久久水密桃| 日韩欧美激情一区| 婷婷开心久久网| 久久久久久99精品| 国产最新精品免费| 欧美大片在线观看一区| 成人激情综合网站| 国产亚洲一区二区三区四区| 精品一区二区精品| 亚洲人成影院在线观看| 欧美www视频| 精品中文字幕一区二区| 最新日韩av在线| 成人av网址在线观看| 日本不卡一区二区| 欧美一区二区成人| 99re成人精品视频| 狠狠色丁香婷综合久久| 亚洲一区二区三区自拍| 欧美性猛交一区二区三区精品| 精品在线免费视频| 亚洲国产精品影院| 91精品国产福利在线观看| 成人亚洲一区二区一| 国产欧美日韩不卡| 国产精品福利一区二区三区| 国产三级精品三级| 色综合久久中文综合久久牛| 99久久精品国产一区二区三区| 亚洲色图视频网| 一个色在线综合| 欧美一卡二卡三卡四卡| 久久婷婷国产综合精品青草| 一区二区三区加勒比av| 国产精品麻豆视频| 久久精品久久久精品美女| 欧美日韩国产欧美日美国产精品| 亚洲一区在线电影| 精品久久五月天| 国产成人欧美日韩在线电影| 国产河南妇女毛片精品久久久| 久久久久久久国产精品影院| 高清不卡一区二区| 欧美一区二区三区视频免费播放| 石原莉奈在线亚洲三区| 久久97超碰国产精品超碰| 26uuu另类欧美亚洲曰本| 97精品久久久午夜一区二区三区| 一区二区欧美国产| 久久久精品人体av艺术| 在线视频你懂得一区| 欧美一区二区在线播放| 国产a级毛片一区| 免费成人小视频| 亚洲欧美中日韩| 亚洲欧美日韩国产综合| 精品国产区一区| 日韩主播视频在线| 2020国产精品| 538prom精品视频线放| 婷婷成人激情在线网| 国产乱色国产精品免费视频| 成人午夜又粗又硬又大| 久久国产尿小便嘘嘘尿| 麻豆精品一区二区av白丝在线| 日韩二区三区四区| 麻豆一区二区三区| 国产一区二区精品在线观看| 国产成人午夜精品影院观看视频 | 一区二区三区精品视频| 一区二区在线观看视频| 国产欧美日韩在线观看| www国产精品av| 亚洲精品一区二区三区精华液| 欧美视频精品在线观看| 91免费国产视频网站| 欧美日韩aaaaaa| 欧美色中文字幕| 99视频精品全部免费在线| 欧美在线你懂的| 日韩成人免费电影| 久久国产福利国产秒拍| 国产福利一区在线观看| 91免费观看国产| 51精品国自产在线| 久久久久久久综合日本| 亚洲日本青草视频在线怡红院| 亚洲午夜精品久久久久久久久| 日韩精品一二三| 国产成人自拍高清视频在线免费播放| 国产99久久久国产精品潘金网站| 色综合久久中文综合久久牛| 日韩一区国产二区欧美三区| 欧美视频中文字幕| 久久亚洲一区二区三区明星换脸 | 97se亚洲国产综合自在线 | 国产精品网站在线播放| 成人av电影免费观看| 久久国产乱子精品免费女| 欧美日本不卡视频| 久久久亚洲精品一区二区三区| 久久精品亚洲麻豆av一区二区 | www国产精品av| 日韩一区在线看| 精品一区二区免费在线观看| 色综合欧美在线视频区| 日韩视频免费观看高清完整版| 欧美激情一区三区| 亚洲18色成人| a亚洲天堂av| 国产亚洲午夜高清国产拍精品| 亚洲欧美经典视频| 国产v日产∨综合v精品视频| 91精品欧美福利在线观看| 中文字幕制服丝袜一区二区三区| 久久国产精品免费| 色噜噜狠狠成人网p站| 国产精品美女久久久久aⅴ国产馆| 亚洲a一区二区| 欧美日韩国产综合久久| 亚洲欧美另类小说| 97久久人人超碰| 99久久er热在这里只有精品15| 91美女片黄在线观看91美女| 国产精品你懂的| 国产黄色精品网站| 亚洲综合成人网| 午夜精品爽啪视频| 精品一区二区三区在线播放 | 国产激情一区二区三区| 欧美一区二区在线播放| 亚洲线精品一区二区三区八戒| www.欧美亚洲| 国产精品久久久爽爽爽麻豆色哟哟 | 99re免费视频精品全部| 91美女在线观看| 午夜精品在线看| 欧美一区二区人人喊爽| 久久99热狠狠色一区二区| 26uuu精品一区二区三区四区在线| 久久精品国产久精国产| 精品国产免费人成电影在线观看四季 | 国产美女一区二区三区| 欧美日本高清视频在线观看| 亚洲综合成人在线视频| 色婷婷精品大在线视频| 亚洲美女区一区| 色婷婷综合久久久中文字幕| 亚洲男帅同性gay1069| 日本高清不卡在线观看| 亚洲私人影院在线观看| 2020国产成人综合网| 国产呦萝稀缺另类资源| 欧美精品一区二区三区在线播放 | jizz一区二区| 1000精品久久久久久久久| 91小视频在线免费看| 亚洲女人小视频在线观看| 一本久道中文字幕精品亚洲嫩| 综合自拍亚洲综合图不卡区| 色国产精品一区在线观看| 夜夜夜精品看看| 欧美一区二区三区在线视频| 免费不卡在线视频| 久久天堂av综合合色蜜桃网| 国产精品亚洲视频| 亚洲人亚洲人成电影网站色| 91久久精品一区二区| 婷婷开心激情综合| 2023国产精品| 91亚洲国产成人精品一区二三| 亚洲精品日韩综合观看成人91| 欧美嫩在线观看| 国产一区二区电影| 亚洲一区在线观看免费| 欧美va在线播放| 91欧美一区二区|