读书人

C++搜索引擎代码解决方案

发布时间: 2013-07-16 22:38:04 作者: rapoo

C++搜索引擎代码
求解这段代码什么意思??
for(int i=1;i<=1;i++)
{
strUrl.Format("http://%s.58.com/xiaoqu/?page=%d",strPUrl,i);
strPageContent=GetDataFromHttp(strUrl);

strPageContent=(char*)ConvertUTF8toGB2312(strPageContent); //属于UTF-8编码
strPageContent.Replace(" ","");
strPageContent.Replace(" ","");
strPageContent.Replace("\"","");
strPageContent.Replace(" ","");



//strHead="<tdclass=img><ahref=http://%s.58.com/xiaoqu/";
strHead.Format("href=http://%s.58.com/xiaoqu/",strPUrl);
// strTail="target=_blank";
strTail=">";
while(strPageContent.Find(strHead)!=-1)
{
strPageContent=strPageContent.Right(strPageContent.GetLength()-strPageContent.Find(strHead)-strHead.GetLength());
strId=strPageContent.Left(strPageContent.Find(strTail));
strPageContent=strPageContent.Right(strPageContent.GetLength()-strPageContent.Find(strTail)-strTail.GetLength());
/* if(strId.Find("\//")<=0) //不含有`两个//
{
continue;
} */
AfxMessageBox("text");
strSubUrl.Format("http://%s.58.com/xiaoqu/%sjieshao/",strPUrl,strId);
//strSubUrl.Format("http://%s.58.com/xiaoqu/%sjieshao/",strPUrl,strId);
strResult=GetDataFromHttp(strSubUrl);
strResult=(char*)ConvertUTF8toGB2312(strResult); //属于UTF-8编码
[解决办法]
循环代码,并且打开http://%s.58.com/xiaoqu/?page=%d这个网址,然后对其进行网页源代码进行分析,提取strHead和strTail之间的数据

读书人网 >C++

热点推荐