本文整理汇总了Golang中github.com/aosen/robot.PageItems类的典型用法代码示例。如果您正苦于以下问题:Golang PageItems类的具体用法?Golang PageItems怎么用?Golang PageItems使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PageItems类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: imgProcess
//下载图片
func (self *PipelineMySQL) imgProcess(pageitems *robot.PageItems, task robot.Task) string {
if img, ok := pageitems.GetItem("img"); ok {
filename, _ := utils.DownloadImage(img, self.ImageStore)
return filename
}
return ""
}
开发者ID:kjfcpua,项目名称:robot,代码行数:8,代码来源:pipeline.go
示例2: Process
func (self *PipelineFile) Process(items *robot.PageItems, t robot.Task) {
self.file.WriteString("----------------------------------------------------------------------------------------------\n")
self.file.WriteString("Crawled url :\t" + items.GetRequest().GetUrl() + "\n")
self.file.WriteString("Crawled result : \n")
for key, value := range items.GetAll() {
self.file.WriteString(key + "\t:\t" + value + "\n")
}
}
开发者ID:kjfcpua,项目名称:robot,代码行数:8,代码来源:pipelinefile.go
示例3: Process
func (self *PipelineConsole) Process(items *robot.PageItems, t robot.Task) {
println("----------------------------------------------------------------------------------------------")
println("Crawled url :\t" + items.GetRequest().GetUrl() + "\n")
println("Crawled result : ")
for key, value := range items.GetAll() {
println(key + "\t:\t" + value)
}
}
开发者ID:kjfcpua,项目名称:robot,代码行数:8,代码来源:pipelineconsole.go
示例4: Process
func (self *PipelineMongo) Process(pageitems *robot.PageItems, task robot.Task) {
items := Items{}
items.Test1, _ = pageitems.GetItem("test1")
items.Test2, _ = pageitems.GetItem("test2")
err := self.c.Insert(&items)
if err != nil {
panic(err)
}
}
开发者ID:aosen,项目名称:robot,代码行数:9,代码来源:mgo.go
示例5: Process
func (self *PipelineMySQL) Process(pageitems *robot.PageItems, task robot.Task) {
if code, ok := pageitems.GetItem("code"); ok && code == "0" {
firstid := self.firstProcess(pageitems, task)
secondid := self.secondProcess(pageitems, task)
picname := self.imgProcess(pageitems, task)
if novelid, err := self.novelProcess(pageitems, task, firstid, secondid, picname); err == nil {
self.contentProcess(pageitems, task, novelid, firstid, secondid)
} else {
log.Println(err.Error())
}
}
}
开发者ID:kjfcpua,项目名称:robot,代码行数:12,代码来源:pipeline.go
示例6: secondProcess
//如果二级分类存在则略过,不存在存储
func (self *PipelineMySQL) secondProcess(pageitems *robot.PageItems, task robot.Task) int64 {
if secondname, ok := pageitems.GetItem("second"); ok {
o := orm.NewOrm()
second := &Second{
Secondname: secondname,
Createtime: time.Now(),
Updatetime: time.Now(),
}
//如果数据不存在 则创建
if _, id, err := o.ReadOrCreate(second, "secondname"); err == nil {
return id
}
}
return -1
}
开发者ID:kjfcpua,项目名称:robot,代码行数:16,代码来源:pipeline.go
示例7: firstProcess
//如果一级分类标签存在则略过,
//不存在则将一级分类标签插入数据库,并存储一级分类标签的id
func (self *PipelineMySQL) firstProcess(pageitems *robot.PageItems, task robot.Task) int64 {
if firstname, ok := pageitems.GetItem("first"); ok {
o := orm.NewOrm()
first := &First{
Firstname: firstname,
Createtime: time.Now(),
Updatetime: time.Now(),
}
if _, id, err := o.ReadOrCreate(first, "firstname"); err == nil {
return id
}
}
return -1
}
开发者ID:kjfcpua,项目名称:robot,代码行数:17,代码来源:pipeline.go
示例8: novelProcess
//添加小说表
func (self *PipelineMySQL) novelProcess(pageitems *robot.PageItems, task robot.Task, firstid, secondid int64, picname string) (int64, error) {
items := pageitems.GetAll()
o := orm.NewOrm()
novel := &Novel{
Title: items["title"],
Firstid: firstid,
Secondid: secondid,
Author: items["author"],
Introduction: items["introduction"],
Picture: picname,
Novelsource: items["novelsource"],
Createtime: time.Now(),
}
//如果数据不存在 则创建
_, id, err := o.ReadOrCreate(novel, "novelsource")
return id, err
}
开发者ID:kjfcpua,项目名称:robot,代码行数:18,代码来源:pipeline.go
示例9: contentProcess
func (self *PipelineMySQL) contentProcess(pageitems *robot.PageItems, task robot.Task, novelid, firstid, secondid int64) {
items := pageitems.GetAll()
chapter, _ := strconv.Atoi(items["chapter"])
o := orm.NewOrm()
content := &Content{
Novelid: novelid,
Title: items["title"],
Firstid: firstid,
Secondid: secondid,
Chapter: chapter,
Subtitle: items["subtitle"],
Text: items["content"],
Contentsource: items["contenturl"],
Createtime: time.Now(),
}
//如果数据不存在 则创建
_, _, err := o.ReadOrCreate(content, "contentsource")
if err == nil {
log.Println("创建content成功 subtitle:", items["subtitle"])
}
}
开发者ID:kjfcpua,项目名称:robot,代码行数:21,代码来源:pipeline.go
注:本文中的github.com/aosen/robot.PageItems类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论