---
title: "简单爬虫算法伪代码"
author: "monkeycn"
date: "2010-12-28T09:29:23Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-12-28T09:31:03Z"
id: 853525
url: "https://monkeycn.iteye.com/blog/853525"
---

```c

// 简单爬虫算法伪代码
// 极品外公 2010.12.28 
// qq:409242642

void run()
{
	hashtable http_table; // 哈希表
	queue txt_queue; // 队列 
	if ( download_http(url, txt) ) // 下载网页
	{
	     get_keyword(txt, keyword); // 提取关键字
	     http_table.append(keyword, url); // 加入到索引表
	     txt_queue.enqueue(txt); // 入队

	     while( !txt_queue.is_empty() )  // 队列不为空
	     {
		 itxt = txt_queue.dequeue(); // 出队
		 foreach( iurl in itxt) // 遍历所有url
		 {
		      if ( download_http(iurl, iitxt) )
		      {
			  get_keyword(iitxt, ikeyword);
			  http_table.append(ikeyword, iurl);
			  txt_queue.enqueue(iitxt); // 入队
		      }
		 }		
	     }
	     
	}
}

```