nosql - 将 redis nosql 与网络爬虫一起使用

标签 nosql redis web-crawler

我正在制作一个简单的维基百科页面爬虫,并将详细信息写入运行 redis 的远程服务器。

 1 The crawler asks the server for a page that needs crawling
 2 The crawler loads the page and adds the pages that are found to an internal buffer
 3 When the page has finished being parsed the results are sent to the server 

我该如何执行以下操作:

保留在服务器上找到的所有页面,并使用一个标志来说明该页面是否已被抓取。

例如

我的问题是。

我如何要求redis给我它的第一个状态为0的链接(尚未爬行) 然后我如何告诉redis将该状态更改为1(在我抓取它之后)

最佳答案

您可以使用列表来保存要处理的页面

RPUSH mylist "http:// ...."

然后你可以使用 lpop 获取列表中的第一项

LPOP mylist

要跟踪已处理的页面,您可以使用一组

SADD myset "http://.....

最后收集地址是否在处理集中

SISMEMBER myset "http://...."

关于nosql - 将 redis nosql 与网络爬虫一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7673767/

相关文章:

symfony - 带有 phpfastcache 包的 Redis 驱动程序

java - 使用 Storm 爬虫对每个域进行不同设置(例如速度)的特定于域的爬行

javascript - 使用 Puppeteer 滚动页面的侧栏

python - Scrapy在长时间运行的过程中多次抓取

database - 如何从 redis 集中检索 id 的内容

javascript - 使用 Firebase-util 连接表时,Firebase 事件未正确触发

mongodb - nosql:MongoDB、Cassandra 或数据仓库的替代方案

MongoDB:如何设置另一个字段(不同于_id)作为mongo文档的ID?

java - 设置方法下hadoop中的共享连接

ruby-on-rails - sidekiq getaddrinfo错误(没有地址)