关于下载网页代码
我要采集这张页面(http://newtrade.jctrans.com/Demand/vxpxhp1673.html)的信息,但不能采集到联系电话,因为要登陆后才能看得到电话.代码如下,为何还是无法采集到联系电话呢?请问要如何实现
void CHtmlDlg::OnButton1()
{
CString strHttpName="http://newtrade.jctrans.com/Demand/vxpxhp1673.html"; // 需要提交数据的页面
CString strFormData = "txtName=chenyang80425&txtPassword=zjj58893035"; // 需要提交的数据,用户名和密码都正确
CInternetSession sess;
CHttpFile* fileGet;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头
try
{
fileGet=(CHttpFile*)sess.OpenURL(strHttpName);//打开文件
}
catch(CException* e)
{
fileGet = 0;
throw;
}
CString strSentence, strGetSentence = "";
if(fileGet)
{
DWORD dwStatus;
DWORD dwBuffLen = sizeof(dwStatus);
BOOL bSuccess = fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwBuffLen);
if( bSuccess && dwStatus>= 200 &&dwStatus<300 )
{
BOOL result = fileGet->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
while(fileGet->ReadString(strSentence)) // 读取提交数据后的返回结果
{
strGetSentence = strGetSentence + strSentence + char(13) + char(10);
}
//AfxMessageBox(strGetSentence); // 显示返回网页内容
this->m_edit=strGetSentence;
UpdateData(FALSE);
}
else
{
strSentence.Format("POST出错,错误码:%d", dwStatus);
AfxMessageBox(strSentence);
}
fileGet->Close();
delete fileGet;
}
else
AfxMessageBox("不能找到网页文件!");
sess.Close();
}
void CHtmlDlg::OnButton1()
{
CString strHttpName="http://newtrade.jctrans.com/Demand/vxpxhp1673.html"; // 需要提交数据的页面
CString strFormData = "txtName=chenyang80425&txtPassword=zjj58893035"; // 需要提交的数据,用户名和密码都正确
CInternetSession sess;
CHttpFile* fileGet;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头
try
{
fileGet=(CHttpFile*)sess.OpenURL(strHttpName);//打开文件
}
catch(CException* e)
{
fileGet = 0;
throw;
}
CString strSentence, strGetSentence = "";
if(fileGet)
{
DWORD dwStatus;
DWORD dwBuffLen = sizeof(dwStatus);
BOOL bSuccess = fileGet->QueryInfo(HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwBuffLen);
if( bSuccess && dwStatus>= 200 &&dwStatus<300 )
{
BOOL result = fileGet->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
while(fileGet->ReadString(strSentence)) // 读取提交数据后的返回结果
{
strGetSentence = strGetSentence + strSentence + char(13) + char(10);
}
//AfxMessageBox(strGetSentence); // 显示返回网页内容
this->m_edit=strGetSentence;
UpdateData(FALSE);
}
else
{
strSentence.Format("POST出错,错误码:%d", dwStatus);
AfxMessageBox(strSentence);
}
fileGet->Close();
delete fileGet;
}
else
AfxMessageBox("不能找到网页文件!");
sess.Close();
}
...全文
相关推荐
下载整个网页源代码的工具
可以下载网站的源代码 很神奇的 可以下载你想要网站的静态源代码 包括css样式表、这个网站的子页面等 可以节省很多时间 提高编程效率 ,希望对大家有用
下载网页源代码和文件的代码
一个网站登录,然后下载网页源代码和文件的代码
禁止网页图片下载代码
个人网页的很多图片是不允许被他人下载或转载的,这组禁止网页图片下载的代码可以起到保护图片被他人下载的目的。
csstp下载网页css代码和图片
自动下载网页css代码和图片,非常实用的一款工具
网页下载器C#源代码
摘要:C#源码,网络相关,网页下载器 网页下载器C#源代码,挺直接简单的一个C#小程序,用来下载指定地址的网页内容,输入地址点击按钮即可下载。


