已知一个PHP网页的地址,如何将其页面显示的内容读出来?并不是要显示出来,而是将读出来的数据放到数组或者边量里
大家给段代码吧……谢谢大家

解决方案 »

  1.   

    HINTERNET hSession;
    HINTERNET hConnection;
    HINTERNET hRequest;hSession = InternetOpen("test", 0, NULL, NULL, 0);

    hConnection = InternetConnect(hSession, g_strVnetIP.c_str(), g_iVnetPort,
    NULL,NULL,INTERNET_SERVICE_HTTP, 0, 1);

    string tempstr = "ReqType=a&BindCommId=b";
    string strFind = g_strVnetUrl;
    strFind += tempstr;

    hRequest = HttpOpenRequest(hConnection, "POST", strFind.c_str(), "HTTP/1.0", NULL,
    NULL, INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE, 1);
    string strHeaders = "Accept:*/*\r\n""Content-Type:application/x-www-form-urlencoded\r\n";
    BOOL bRet = HttpSendRequest(hRequest, strHeaders.c_str(), lstrlen(strHeaders.c_str()), NULL, 0);

    if (!bRet)
    {
    g_pAppLogger->OutputAppLog("GetVnetBill -HttpSendRequest failed:%d",bRet);
    InternetCloseHandle(hRequest);
    InternetCloseHandle(hConnection);
    InternetCloseHandle(hSession);
    return -1;
    }

    string strRecv;
    char szBuffer[1024];
    DWORD dwRead = 0;
    while (InternetReadFile(hRequest, szBuffer, sizeof(szBuffer), &dwRead))
    {
    if(dwRead != 0)
    strRecv.append(szBuffer, dwRead);
    else
    break;
    } InternetCloseHandle(hRequest);
    InternetCloseHandle(hConnection);
    InternetCloseHandle(hSession);读出来的字符串在strRecv里