3,055
社区成员
发帖
与我相关
我的任务
分享
<!--day 1-->
<table class="yuBaoTable" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" rowspan="2" class="t0" style="background:#f4f7fc;">26日星期五</td>
<td width="12%" style="background:#f4f7fc;">白天</td>
<td width="10%">
<a href="http://www.weather.com.cn/static/html/legend.shtml" target="_blank">
<img src="/m2/i/icon_weather/29x20/d00.gif" />
</a>
</td>
<td width="18%"><a href ="http://baike.weather.com.cn/index.php?doc-view-767.php" target="_blank">晴</a></td>
<td width="15%">
<a href="http://baike.weather.com.cn/index.php?doc-view-1148.php" target="_blank">
<b>高温 <strong>23<strong>℃</b>
</a>
</td>
<td width="15%">
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
无持续风向
</a>
</td>
<td width="15%">
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
微风
</a>
</td>
</tr>
<tr>
<td style="background:#f4f7fc;">夜间</td>
<td>
<a href="http://www.weather.com.cn/static/html/legend.shtml" target="_blank">
<img src="/m2/i/icon_weather/29x20/n00.gif" />
</a>
</td>
<td><a href ="http://baike.weather.com.cn/index.php?doc-view-767.php" target="_blank">晴</a></td>
<td>
<a href="http://baike.weather.com.cn/index.php?doc-view-1386.php" target="_blank">
<span>低温 <strong>16<strong>℃</span>
</a>
</td>
<td>
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
无持续风向
</a>
</td>
<td>
<a href="http://baike.weather.com.cn/index.php?doc-view-778.php" target="_blank">
微风
</a>
</td>
</tr>
</table>
BOOL bNext1=FALSE,bNext2=FALSE,bNext3=FALSE;
int leftpos=0; //取某行源码“</TD>”的位置
int rightpos=0; //取某行源码“>”的位置
int isel=m_reportlist.GetSelectionMark();
if(isel<0)
{
AfxMessageBox("请选择城市");
return;
}
address.Format("%s/%s.html",addressfront,city2[isel][1]);
strtmp1.Format("city\" >%s",city2[isel][0]);
CString strsource;
CInternetSession mySession(NULL,0);
CHttpFile* myHttpFile=NULL;
myHttpFile=(CHttpFile*)mySession.OpenURL(address);
while(myHttpFile->ReadString(strsource))
{
//如果某行源码中有提取的字符,开始进行处理
if(strsource.Find(strtmp1)>0)
bNext1=TRUE;
if(bNext1)
{
int leftpos=strsource.Find("map-layer-weaher");
if(leftpos>0)
{
strtmp2=strsource.Right(strsource.GetLength()-strlen("map-layer-weaher")-leftpos-2);
rightpos=strtmp2.Find("</div>");
strtmp2=strtmp2.Left(rightpos);
strweather=strtmp2;
bNext1=FALSE;
bNext2=TRUE;
}
}
if(bNext2)
{
int leftpos=strsource.Find("map-layer-temp");
if(leftpos>0)
{
strtmp2=strsource.Right(strsource.GetLength()-strlen("map-layer-temp")-leftpos-2);
rightpos=strtmp2.Find("</div>");
strtmp2=strtmp2.Left(rightpos);
strtemperature=strtmp2;
bNext2=FALSE;
bNext3=TRUE;
}
}
if(bNext3)
{
int leftpos=strsource.Find("map-layer-wind");
if(leftpos>0)
{
strtmp2=strsource.Right(strsource.GetLength()-strlen("map-layer-wind")-leftpos-2);
rightpos=strtmp2.Find("</div>");
strtmp2=strtmp2.Left(rightpos);
strwind=strtmp2;
bNext3=FALSE;
goto end;
}
}
}
end:
myHttpFile->Close();
mySession.Close();
m_reportlist.SetItemText(isel,1,strweather);
m_reportlist.SetItemText(isel,2,strtemperature);
m_reportlist.SetItemText(isel,3,strwind);