资源简介
VC++6.0写的网络爬虫程序,多线程,生成文件,很不错的学习资料,转载的~谢谢

代码片段和文件信息
////////////////////////////////////////////////////
//设计者姓名:LWZ小组 刘克东 00348231
//项目名:大实习-搜索引擎-网络化爬虫
//创建日期:2004-12-10
//最近一次修改日期:2004-12-26
//
// DownloadData.cpp: implementation of the DownloadData class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “NetCrawler.h“
#include “afxmt.h“
#include “DownloadData.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DownloadData::DownloadData()
{
uCur_URLnum=0; //初始化当前队列中URL数量为0
uMaxSizeOfContainer=4000; //URL队列最大容量
uCur_URLptr=0; //当前队列头部指针
uCur_ActiveThread=0; //当前活动线程数量为0
uMaxThreadNum=10; //初始化线程数目10
uCur_Fileid=1; //初始化本地文件名称为1
str_LocalDir=“C:\\“; //初始化本地文件目录为C:
}
DownloadData::~DownloadData()
{
}
//是否URL队列已经满了
bool DownloadData::IsEmpty()
{
criSection.Lock();
bool r=(uCur_URLnum<=uCur_URLptr);
criSection.Unlock();
return r;
}
//是否URL已经存在于队列中
bool DownloadData::IsExisted(CString &str)
{
criSection.Lock();
for(UINT i=0;i {
if(URLcontainer[i]==str)
{
criSection.Unlock();
return TRUE;
}
}
criSection.Unlock();
return FALSE;
}
//是否URL队列空了(无未处理的URL)
bool DownloadData::IsFull()
{
criSection.Lock();
bool r=(uCur_URLnum==uMaxSizeOfContainer);
criSection.Unlock();
return r;
}
//获得当前活动线程数目
UINT DownloadData::GetCurThread()
{
criSection.Lock();
UINT n=uCur_ActiveThread;
criSection.Unlock();
return n;
}
//获得最大线程数目
UINT DownloadData::GetMaxThreadnum()
{
return uMaxThreadNum;
}
//线程开始,向数据区添加一个线程记录成功返回true
bool DownloadData::AddThread()
{
criSection.Lock();
if(uCur_ActiveThread==uMaxThreadNum)
{
criSection.Unlock();
return FALSE;
}
uCur_ActiveThread++;
criSection.Unlock();
return TRUE;
}
//线程结束后,从数据区删除一个线程记录,成功返回true
bool DownloadData::DeleThread()
{
criSection.Lock();
if(uCur_ActiveThread==0)
{
criSection.Unlock();
return FALSE;
}
uCur_ActiveThread--;
criSection.Unlock();
return TRUE;
}
//从共享数据区URL队列头取出一个URL
bool DownloadData::GetCurURL(CString &str)
{
criSection.Lock();
if(uCur_URLptr>=uCur_URLnum)
{
criSection.Unlock();
return FALSE;
}
str=URLcontainer[uCur_URLptr];
uCur_URLptr++;
criSection.Unlock();
return TRUE;
}
//向共享数据区URL队列尾添加一个URL
bool DownloadData::AddURL(CString &str)
{
criSection.Lock();
if(uCur_URLnum==uMaxSizeOfContainer)
{
criSection.Unlock();
return FALSE;
}
URLcontainer[uCur_URLnum]=str;
uCur_URLnum++;
criSection.Unlock();
return FALSE;
}
//获得当前本地存储文件的地址
void DownloadData::GetFileName(CString &str)
{
criSection.Lock();
CString str_temp;
str_temp.Format(“%d“uCur_Fileid);
str=str_LocalDir+str_temp+“.txt“;
uCur_Fileid++;
criSection.Unlock();
}
//根据用
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 402 2004-12-13 23:33 res\NetCrawler.rc2
文件 1078 2004-12-13 23:33 res\NetCrawler.ico
..A.SH. 3072 2007-05-22 21:05 res\Thumbs.db
文件 3633 2007-05-22 10:10 DownloadData.cpp
文件 2771 2007-05-22 15:11 DownloadData.h
文件 13964 2007-05-22 19:14 MainThread.cpp
文件 2463 2007-05-22 15:11 MainThread.h
文件 22876 2007-05-22 10:03 NetCrawler.aps
文件 2760 2007-05-22 20:02 NetCrawler.clw
文件 3538 2007-05-22 10:10 NetCrawler.cpp
文件 4736 2004-12-20 17:12 NetCrawler.dsp
文件 545 2004-12-13 23:33 NetCrawler.dsw
文件 1554 2004-12-25 20:53 NetCrawler.h
文件 56832 2007-05-22 19:29 NetCrawler.opt
文件 1574 2007-05-22 15:12 NetCrawler.plg
文件 7620 2004-12-25 00:37 NetCrawler.rc
文件 7304 2007-05-22 13:20 NetCrawlerDlg.cpp
文件 2707 2007-05-22 13:20 NetCrawlerDlg.h
文件 3627 2007-05-22 13:20 ProjectDlg.cpp
文件 2118 2007-05-22 13:20 ProjectDlg.h
文件 3651 2004-12-13 23:33 ReadMe.txt
文件 1377 2004-12-25 00:28 Resource.h
文件 212 2004-12-13 23:33 StdAfx.cpp
文件 1054 2004-12-13 23:33 StdAfx.h
目录 0 2007-05-22 10:03 res
----------- --------- ---------- ----- ----
151686 26
- 上一篇:数据结构 银行排队系统
- 下一篇:C++实现的非常好的一个矩阵类
相关资源
- VC++ 多线程文件读写操作
- 移木块游戏,可以自编自玩,vc6.0编写
- MFC数字钟(基于VC6.0)
- 安科瑞智能电能表MODBUS通讯程序 VC6
- VC++MFC小游戏实例教程(实例)+MFC类库
- VC6LineNumberAddin.dll
- 用VC6.0实现多边形扫描线填充算法
- 6自由度机器人运动学正反解C++程序
- 基于C语言实现的网络爬虫(搜索引擎
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- VC助手 VC6.0助手
- 使用LCD9648显示文字
- Wi-Fi IoT智能家居套件-Hi3861(原理图
- Quectel_EC200xEG912YEC600NEC600S系列_TCP(I
- 国民技术SKY6610T 软硬件开发资料
- 基于STM32F103ZET6控制舵机旋转(ts90a/
- ESP8266-01S(使用手册+固件库+烧录工具
- stm32f103zet6控制蓝牙小车
- UDS基础框架
- 基于Arduino的MLX90614温度采集程序
- ADS1263驱动程序+电路图
- STM32-ads1256
- ADS1256-STM32参考程序
- stm32 AD7506
- stc-isp-15xx-v6.86G
- stm32f103c8t6开发板原理图+pcb
- ASR6500,ASR6505原厂测试代码
- 显示屏操作(stm32f103c8t6(SAN))
- Proteus 8.6仿真STM32F103C6
评论
共有 条评论