Web页面分析(转到下一页面不正常)

runsoft 2008-12-21 10:44:16
我使用IWebBrowse2 来实现的
在IWebBrowse2 的 OnDocumentCompleteExplorer1中执行了两个函数.
{
CComQIPtr< IWebBrowser2 > spBrowser = pDisp;
CComPtr < IDispatch > spDispDoc;
spBrowser->get_Document( &spDispDoc );
CComQIPtr< IHTMLDocument2 > spDocument2 = spDispDoc;
CString strUrl,strTemp;

//登入邮件
strUrl = this->m_internetexplorer .GetLocationURL ();//得到当前网页的URL

if (strUrl=="https://login.yahoo.co.jp/config/login?")
{

Loginemail(spDocument2);
return;
}
//上面都很正常

//进入写邮件

if (strUrl=="http://www.yahoo.co.jp/")
{
//执行下面这个函数有问题 页面可以自动转到 http://www.yahoo.co.jp/ 当中去
Linkemail_1(spDocument2); return;

}
}

//下面是函数定义

bool Linkemail_1(IHTMLDocument2* pHTMLDoc2)
{

IHTMLElementCollection* pElementCol=NULL;
HRESULT hr;
USES_CONVERSION;
CComQIPtr< IHTMLElementCollection > spElementCollection;
CComPtr<IHTMLElement> pElement;
hr = pHTMLDoc2->get_forms( &spElementCollection ); //取得表单集合
if ( FAILED( hr ) )
{
AfxMessageBox("获取表单的集合 IHTMLElementCollection 错误");
return false;
}

long nFormCount=0; //取得表单数目
hr = spElementCollection->get_length( &nFormCount );
if ( FAILED( hr ) )
{
AfxMessageBox("获取表单数目错误");
return false;
}

for(long i=0; i<nFormCount; i++)
{
IDispatch *pDispatch = NULL; //取得第 i 项表单
hr = spElementCollection->item( CComVariant( i ), CComVariant(), &pDispatch );

if ( FAILED( hr ) ) continue;

IHTMLElement* pElement=NULL;
hr = pDispatch->QueryInterface(IID_IHTMLElement,(void**)&pElement);
if ( FAILED( hr ) )
{
AfxMessageBox("获取表单数目错误");
return false;
}

IHTMLInputTextElement* pInputElement=NULL;
if ( pDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement)==0)
{
//这里怎么也获取不到信息 页面上有很多 IHTMLInputTextElement类型的.我直接打开下栽的页面看过
AfxMessageBox("lssrc");


}
}

return true;


}
...全文
72 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
scems 2008-12-21
  • 打赏
  • 举报
回复
up
wap21 2008-12-21
  • 打赏
  • 举报
回复
up

3,055

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC HTML/XML
社区管理员
  • HTML/XML社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧