dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Enable javascript in CInternetSession

  1. #1
    Join Date
    Jan 2009
    Posts
    246

    Enable javascript in CInternetSession

    Hi. I am trying to get a web page source using CInternetSession, just like this:
    Code:
    BOOL CCIFDoc::GetRemoteFile(CString sServer, CString sRemotePath, CString sParameter, CStringArray& saData)
    {
    	BOOL bRet = FALSE;
    	CInternetSession ISession;
    	CInternetFile* pIFile = NULL;
    	CHttpFile* pHttpFile = NULL;
    	LPCTSTR lpszAccept[] = {_T("*/*"), NULL};
    
    	try
    	{
    		pIFile = (CInternetFile*)ISession.OpenURL(_T("http://") + sServer + sRemotePath + sParameter, 1, INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD);
    		if(NULL != pIFile)
    		{
    			CString sTemp;
    			while(pIFile->ReadString(sTemp))
    				saData.Add(sTemp + _T("\n"));
    		}
    
    		bRet = (saData.GetSize() > 0);
    	}
    	catch(CInternetException* pException)
    	{
    		pException->GetErrorMessage(m_sError.GetBuffer(_MAX_PATH), _MAX_PATH);
    		m_sError.ReleaseBuffer();
    		pException->Delete();
    	}
    	catch(CMemoryException* pMemException)
    	{
    		pMemException->GetErrorMessage(m_sError.GetBuffer(_MAX_PATH), _MAX_PATH);
    		m_sError.ReleaseBuffer();
    		pMemException->Delete();
    	}
    
    	if(NULL != pIFile)
    	{
    		pIFile->Close();
    		delete pIFile;
    	}
    
    	if(NULL != pHttpConnect)
    	{
    		pHttpConnect->Close();
    		delete pHttpConnect;
    	}
    
    	ISession.Close();
    
    	return bRet;
    }
    and goes fine for most of pages … however, there is some pages without <body> part (which is important to me), and with message:
    Code:
    <noscript>Please enable JavaScript to view the page content.</noscript>
    How can setup CInternetSession and his siblings (CInternetFile, CHttpFile, etc.) in order to get these pages too ? Is there possible ?
    Last edited by mesajflaviu; May 16th, 2018 at 03:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)