How can I control MS Browser by using software?

Posted on October 31st, 2009 by admin

What I want to do is run a program that goes to a site, enters an area on that site, and does multiple searches, saving the results to a text file.

I need to make sure the searches complete correctly, I need to know if the resultant records exceed 200 (the file is then truncated), I need to be able to capture errors and process them (perhaps not in real time – correcting the errors, but to be aware that the errors occured so that I can work around them later).

So is there software out there that can help me? I used to use White Knight on a Mac and it worked great, but alas it was only for dialup, I also used Hyperlink but it too didn’t make the leap to the web.

It would be nice if there was existing programs so I didn’t need to start a new career to solve this problem.

Thank you for your help and suggestions.

I´ve been using an MFC based sample program and twisting it to suit my needs. You could do the same without much effort.

//this code excerpt also demonstrates try/catch exception handling
#include <afxinet.h>
//assumes server, port, and URL names have been initialized
CInternetSession session("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
try
{
CString strServerName;
INTERNET_PORT nPort;

pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);

if (dwRet == HTTP_STATUS_OK)
{
UINT nRead = pFile->Read(szBuff, 1023);
while (nRead > 0)
{
//read file…
}
}
delete pFile;
delete pServer;
}
catch (CInternetException* pEx)
{
//catch errors from WinInet
}
session.Close();

One Response

  1. rentaprogrammer Says:

    I´ve been using an MFC based sample program and twisting it to suit my needs. You could do the same without much effort.

    //this code excerpt also demonstrates try/catch exception handling
    #include <afxinet.h>
    //assumes server, port, and URL names have been initialized
    CInternetSession session("My Session");
    CHttpConnection* pServer = NULL;
    CHttpFile* pFile = NULL;
    try
    {
    CString strServerName;
    INTERNET_PORT nPort;

    pServer = session.GetHttpConnection(strServerName, nPort);
    pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject);
    pFile->AddRequestHeaders(szHeaders);
    pFile->SendRequest();
    pFile->QueryInfoStatusCode(dwRet);

    if (dwRet == HTTP_STATUS_OK)
    {
    UINT nRead = pFile->Read(szBuff, 1023);
    while (nRead > 0)
    {
    //read file…
    }
    }
    delete pFile;
    delete pServer;
    }
    catch (CInternetException* pEx)
    {
    //catch errors from WinInet
    }
    session.Close();
    References :
    http://msdn2.microsoft.com/en-us/library/sb35xf67(VS.80).aspx

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

|
  • Categories

  • Pages

  • Tags

  • Archives

  • Meta

  •