Originally posted by: Ofer Erlich
Hi,
I use your code and wanted to pass the function a CString object that was taken from a CEdit , but it doesn't work.
I get a message "The URL does not use a recognised protocol"
I notice you said you need to use the command with _T(string) command why?
What can be done to use the way I want?
Originally posted by: Tim
I tried to use a variant of your code to retrieve a *.jpg off a network machine from a known location:
[code]
file = (CHttpFile*) session.OpenURL(theUrl, dwContext, dwFlags, pstrHeaders, dwHeadersLength);
// most of the following deals with storing the html to a file
if (file)
BOOL bIsOk = dataStore.Open(_T(".\\rawHtml.jpg"),
if (!bIsOk)
// continue fetching code until there is no more
While this doesn't error out, the file it creates is not a readable *.jpg image. What am I doing wrong here?
Regards,
- Tim Manchester
Howdy,
BOOL CHttpTestDlg::GetJPG(CString theUrl)
{
// this first block does the actual work
CInternetSession session;
CHttpFile* file = NULL;
try
{
// try to connect to the URL
DWORD dwContext = 1;
DWORD dwFlags = INTERNET_FLAG_TRANSFER_BINARY;
LPCTSTR pstrHeaders = NULL;
DWORD dwHeadersLength = 0;
}
catch (CInternetException* m_pException)
{
// set file to NULL if there's an error
file = NULL;
m_pException->Delete();
}
CStdioFile dataStore;
{
CString somecode;
CFile::modeCreate
| CFile::modeWrite
| CFile::shareDenyWrite
| CFile::typeBinary);
//| CFile::typeText);
return FALSE;
while (file->ReadString(somecode) != NULL)
{
dataStore.WriteString(somecode);
}
file->Close();
delete file;
}
else
{
dataStore.WriteString(_T("Could not establish a connection with the server..."));
}
}
[/code]
Originally posted by: tigrisha
Doesnt work throught HTTPS proxy. Please help me to complete this to working example :)
ReplyOriginally posted by: Nathan Franklin
I have tried this code with win2k... and it just freezes up.... and doesnt retreive the webpage code.. Is there anything special i need to do?
ReplyOriginally posted by: Wang
If I want to check the web content before being displayed?
for example ,I want search some key workd in the web content.
how can i implement this?
Any idea?
millions of thanks
Originally posted by: Thomas Wang
I have tried to read loop until CString find </html> but It doesn't work!
I tried to continue read about 3 times using ReadString(sCurLine) when it returns NULL ,but I found that when the ReadString returns NULL whether you read again or not it always returns NULL!
My God! What can I do?
How can MS IE get this Web Page?
Originally posted by: Thomas Wang
What I mean broken Web Page is that the Web page I got has no "</html>" in the end of file. It just contain the head of Web page.
I try it again and again and sometimes it is complete transfered sometimes it is broken.
But I use the Borland Delphi's NMHTTP component to get this page . It works well. I try it 8 times and only get the borken page 1 time.
What can I do?
Originally posted by: Thomas Wang
I program a App like your code.
But sometimes the web page that I get is incompiete,it is just part of the html file .
But when I paste the url into IE,IE can show the whole page.
Do you know how to solve it?
Originally posted by: Jackson Lai
My application would like to connect to a running instance of IE and then parse the whole HTML document so that I will get a list of URL links (href) and other objects such as textboxes and images. Is it possible to achieve this?
Thank you very much.
Reply
Originally posted by: Bruce Drummond
Here is a one liner to do the same thing. Enjoy!
HRESULT URLDownloadToFile(
LPUNKNOWN pCaller,
LPCTSTR szURL,
LPCTSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
);