使用闭包函数的类 Scrapy 的 Go 爬虫框架——Goribot

https://github.com/zhshch2002/goribot

  • Goroutine原生支持并发
  • 使用匿名函数实现蜘蛛处理逻辑
  • 使用Pipeline插入生命周期钩子实现扩展

README里有完整的Bilibili爬虫实例。使用了Pipeline和闭包函数的设计。
简单实例:

package main

import (
    "encoding/json"
    "fmt"
    "github.com/zhshch2002/goribot"
)

func main() {
    s := goribot.NewSpider()
    _ = s.Get(nil, "https://httpbin.org/get?Goribot%20test=hello%20world", func(r *goribot.Response) {
        m := make(map[string]interface{})
        err := json.Unmarshal([]byte(r.Text), &m)
        if err != nil {
            fmt.Println(err)
        }
        fmt.Println(m)
    })
    s.Run()
}
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!