【发布时间】:2014-06-24 20:14:25
【问题描述】:
我正在使用 Groovy on Grails 和后端的 MongoDB 制作网络爬虫。我不确定如何为域类建模。
例如:
域类网站包含用户已预先保存并希望抓取的网站。 模型网站包含:www.google.com 抓取 www.google.com 后,我得到以下信息:
www.a.com resource types other metrics
www.b.com resource types other metrics
www.c.com resource types other metrics
www.d.com resource types other metrics
我想将它们存储在数据库中并继续爬取。同样,www.a.com 在被抓取时会产生更多的网址,例如:
www.a1.com resource types other metrics
www.a2.com resource types other metrics
对于所有其他 url,它们也会有子 URL。如何为它建模域类?我的一个想法是有一个域类(将与自身关联)如下,但我不确定它是否正确:
class Resource implements Comparable {
String url
String otherMetrics
SortedSet subResources
static hasMany = [subResources: Resource]
static belongsTo = [parent: Resource]
}
【问题讨论】:
-
投反对票的人请给出你投反对票的理由
标签: mongodb grails dns web-crawler