if(err!=ERR_NO)
{
weather->gd=0;
printf("day wing error: %s\n",get_err_info(err));
}
}
if(strstr(rline,NIGHT_TAG_STRING))
{
flag=2;
//printf("%s\n",rline);
//get day weather information.
weather->gnt=1;
err_info err;
while(!strstr(fgets(rline,LINE_LEN,fp),"
get_detail_from_html(rline,weather->night.t,sizeof(weather->night.t),"span",&err);
if(err!=ERR_NO)
{
weather->gd=0;
printf("night t error: %s\n",get_err_info(err));
}
fgets(rline,LINE_LEN,fp);
get_detail_from_html(rline,weather->night.type,sizeof(weather->night.type),"li",&err);
if(err!=ERR_NO)
{
weather->gd=0;
printf("night type error: %s\n",get_err_info(err));
}
fgets(rline,LINE_LEN,fp);
get_detail_from_html(rline,weather->night.wing,sizeof(weather->night.wing),"li",&err);
if(err!=ERR_NO)
{
weather->gd=0;
printf("night wing error: %s\n",get_err_info(err));
}
}
}
fclose(fp);
return 0;
}
################################
get_detail_from_html.h
#ifndef GET_DETAIL_FROM_HTML_H
#define GET_DETAIL_FROM_HTML_H
typedef enum _err_info
{
ERR_NO=0,
ERR_NOT_FIND,
ERR_DST_SHORT
}err_info;
char* get_detail_from_html(const char* source,char* dst,size_t s_t,const char* html_flag,err_info* err);
char* get_err_info(err_info err);
#endif //GET_DETAIL_FROM_HTML_H
###############################