待解决
来源:互联网 发布:编程珠玑百度云 编辑:程序博客网 时间:2024/04/28 20:23
int CCrawlAdapter::MediaMath(const char* strData,const char* url,const char* Ip,const char* domain)
{
if(strData == NULL || strlen(strData) == 0)
return -1;
int size = strlen(strData);
char* pData = new char[size + 1];
memcpy(pData,strData,size);
pData[size] = 0;
char* info = pData;
NetMediaAlarm_t medAlarm;
memset(&medAlarm,0,sizeof(medAlarm));
strcpy(medAlarm.SubIP,Ip);
strcpy(medAlarm.Domain,domain);
strcpy(medAlarm.PageUrl,url);
int len = 0;
while(len < size)
{
LOWCODE(pData[len],pData[len]);
len++;
}
len=0;
// embed img
//去头
while(*pData != '<' && *pData != 0)
{
pData++;
}
if(*pData == 0)
{
delete []info;
info = NULL;
pData = NULL;
return 0;
}
char* pStart = NULL;
char* pEnd = NULL;
//先找图片
pStart = strstr(pData,"<img");
if(pStart != NULL)
{
while(pStart != NULL && *pStart != '/0')
{
len = 0;
pStart += 4;
pStart = strstr(pStart ,"src");
if(pStart != NULL)
{
pStart +=3;
while(*pStart != '/"' && *pStart != '/'' && *pStart != '/' && ( *pStart < 'a' || *pStart >'z') && *pStart != '/0' )
pStart++;
if(*pStart == 0)
{
break;
}else if (*pStart == '/"' || *pStart == '/'')
{
pStart++;
while( (*pStart <'a' || *pStart > 'z') && *pStart != '/' && *pStart != '>' && *pStart != '#' && *pStart != '/"' && *pStart != '/'')
{
pStart++;
}
pEnd = pStart;
while(*pEnd != '/"' && *pEnd != '/'' /*&& *pEnd != 0*/ && *pEnd != ' ' && *pEnd != '>' && *pEnd != '#')
{
pEnd++;
len++;
}
}else if (*pStart == '/' || ( *pStart > 'a' && *pStart <'z') )
{
pEnd = pStart;
while(*pEnd != ' ' && *pEnd != '>' && *pEnd != ',' /*&& *pEnd != 0*/)
{
pEnd++;
len++;
}
}
if(len > 0)
{
GetCurTime(medAlarm.MediaDate,20);
char tmp[512] = {0};
memcpy(tmp,pStart,len);
MediaParam mTmp;
memset(&mTmp,0,sizeof(MediaParam));
if(strstr(tmp,"http://") == NULL)
{
int urllen = len + 9 + strlen(domain);
char* p = new char[urllen+1];
if(tmp[0] == '/')
{
snprintf(p,urllen+1,"http://%s%s",domain,tmp);
}
else
{
snprintf(p,urllen+1,"http://%s/%s",domain,tmp);
}
p[urllen] = 0;
snprintf(medAlarm.MediaUrl,512,"%s",p);
mTmp = GetImgSize(p,urllen);
snprintf(medAlarm.justsign,64,"%d %s",mTmp.nsize,mTmp.lastModified);
snprintf(medAlarm.stype,8,"%s",mTmp.stype);
Alarm(medAlarm,IM_RM_RESPONSE_MATCHIMAGE);
delete []p;
p = NULL;
}
else
{
char* p2 = strstr(tmp,"http://");
strcpy(medAlarm.MediaUrl,p2);
mTmp = GetImgSize(p2,strlen(p2));
snprintf(medAlarm.justsign,64,"%d %s",mTmp.nsize,mTmp.lastModified);
snprintf(medAlarm.stype,8,"%s",mTmp.stype);
Alarm(medAlarm,IM_RM_RESPONSE_MATCHIMAGE);
}
}
if(pStart != NULL && *pStart != 0)
pStart = strstr(pStart,"<img");
}
}
}
//vedio
pData = (char*)info;
while(*pData != '<')
pData++;
pStart = strstr(pData,"<embed");
if(pStart == NULL)
{
delete []info;
info = NULL;
pData = NULL;
return 0;
}
while(pStart != NULL && *pStart != '/0')
{
len = 0;
pStart += 6;
pStart = strstr(pStart ,"src");
if(pData != NULL)
{
pStart +=3;
while( *pStart != '/"' && *pStart != '/'' && *pStart != '/' && ( *pStart < 'a' || *pStart >'z') && *pStart != '/0')
pStart++;
if(*pStart == 0)
{
break;
}else if (*pStart == '/"' || *pStart == '/'')
{
pStart++;
while( (*pStart <'a' || *pStart > 'z') && *pStart != '/' && *pStart != '>' && *pStart != '#' && *pStart != '/"' && *pStart != '/'')
{
pStart++;
}
pEnd = pStart;
while(*pEnd != '/"' && *pEnd != '/'' /*&& *pEnd != 0*/ && *pEnd != ' ' && *pEnd != '>' && *pEnd != '#' )
{
pEnd++;
len++;
}
}else if (*pStart == '/' || ( *pStart >= 'a' && *pStart <='z'))
{
pEnd = pStart;
while(*pEnd != ' ' && *pEnd != '>' && *pEnd != ',' /*&& *pEnd != 0*/)
{
pEnd++;
len++;
}
}
if(len > 0)
{
GetCurTime(medAlarm.MediaDate,20);
char tmp[512] = {0};
memcpy(tmp,pStart,len);
MediaParam mTmp;
memset(&mTmp,0,sizeof(MediaParam));
if(strstr(tmp,"http://") == NULL)
{
int urllen = len + 9 + strlen(domain);
char* p = new char[urllen+1];
if(tmp[0] == '/')
{
snprintf(p,urllen+1,"http://%s%s",domain,tmp);
}
else
{
snprintf(p,urllen+1,"http://%s/%s",domain,tmp);
}
p[urllen] = 0;
snprintf(medAlarm.MediaUrl,512,"%s",p);
mTmp = GetImgSize(p,urllen);
snprintf(medAlarm.justsign,64,"%d %s",mTmp.nsize,mTmp.lastModified);
snprintf(medAlarm.stype,8,"%s",mTmp.stype);
Alarm(medAlarm,IM_RM_RESPONSE_MATCHVODIEO);
delete []p;
p = NULL;
}
else
{
char* p2 = strstr(tmp,"http://");
strcpy(medAlarm.MediaUrl,p2);
mTmp = GetImgSize(p2,strlen(p2));
snprintf(medAlarm.justsign,64,"%d %s",mTmp.nsize,mTmp.lastModified);
snprintf(medAlarm.stype,8,"%s",mTmp.stype);
Alarm(medAlarm,IM_RM_RESPONSE_MATCHVODIEO);
}
}
if(*pStart != 0 && pStart != NULL)
pStart = strstr(pStart,"<embed");
}
}
delete []info;
info = NULL;
pData = NULL;
return 1;
}
- 待解决
- 待解决
- 待解决
- 待解决
- 待解决
- 待解决
- 待解决
- 待解决
- 待解决
- 待解决的存疑
- 待解决的问题
- ??待解决---整数除法
- 待解决的问题
- 待解决的问题
- 问题待解决
- 待解决的问题
- 待解决的问题
- 待解决疑问
- (十二)幸福之家 - 4
- Class 及instanceof关键字的应用
- REST SOAP 和 XML-RPC
- 很受欢迎的Linux笔记(一)
- static全局变量与普通的全局变量有什么区别?
- 待解决
- PL_SQL developer 导入导出数据
- ORA-01791:not a SELECTed expression 处理
- 多选框1
- 有用的链接...
- 在Windows XP/2003 Server上彻底删除Oracle10g/9i
- 本地sql数据库怎么与远程sql数据库同步?
- js总结0(多选框,新增时将选中的项列在文本框中,修改时不仅列出原有的还要可以修改)
- SQL Server 2000订阅与发布的具体操作