⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dealevent.cpp

📁 小型搜索引擎,用C/C++编写,属于全文搜索引擎
💻 CPP
字号:
#include "Tse.h"#include "HttpTse.h"using namespace std;extern int FindUrl(const char *url, char **content);extern int FindKey(const char *key);void DoSearch(){	for(;;){		cout << "*********************************************" << endl;		cout << "Tse searching mode." << endl;		cout <<	"*********************************************" << endl;		cout << "a.Search a key word" << endl;		cout << "b.Search a URL" << endl;		cout << "c.Exit" << endl;		cout << "*********************************************" << endl;		string c;		for(;;){			cin >> c;			if( c == "a" || c == "b" || c == "c" ) break;		}		if( c == "a"){			cout << "Please enter the query words:" << endl;			string s;			cin >> s;			int num = FindKey(s.c_str());			cout << "There are " << num << " pages containing the key,"				<< " see the above information." << endl << endl;			continue;		}		if( c == "b"){			cout << "Please enter the url:" << endl;			string s;			cin >> s;			char *sContentBuf=NULL;			if( FindUrl(s.c_str(), &sContentBuf) == -1 ){                        	printf("Haven't found the url.\n");			}else{				//cout << content << endl;				for(unsigned int i=512; (i<strlen(sContentBuf))&&(i<600); i++){					if((sContentBuf[i] == '\n') || (sContentBuf[i] == '\r')){						sContentBuf[i] = '\0';						break;					}					if(i == 599){						sContentBuf[i] = '\0';					}				}				cout << endl << sContentBuf << endl << "......" << endl << endl;				if( sContentBuf) free(sContentBuf);			}			cout << "b over" << endl;			continue;			                }		if( c == "c" ) exit(0);	}}void DoHelp(){	cout << "Tse 1.0" << endl;	cout << "Tiny Web Searching Engine, July 2003" << endl;	cout << "Syntax:" << endl;	cout << "\tTse -c inputFileName outputFileName" << endl;	cout << "\tTse -s" << endl;	cout << "The input file contains a list of URLs for crawling.-c is to crawl all urls of inutFileName, and to save parsed links in outputFileName file. -s is a searching mode.In the extended mode,all the hypertext links in the webpages will be stored in the outputfile in the same format as the input file." << endl;	exit(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -