ฉันกำลังทำอะไรบางเว็บขันโดยใช้ colly แต่อยากวิ่งหนีมันเป็นบางครั้งต่อเมื่อต้องใช้ตารางงานของ. ฉันพยายามออกมาเป็นพื้นฐานเข้าใกล้มัน
type scraper struct {
coll *colly.Collector
rc *redis.Client
}
func newScraper(c *colly.Collector, rc *redis.Client) scraper {
return scraper{coll: c, rc: rc}
}
func main() {
rc := redis.NewClient(&redis.Options{
Addr: "localhost:3000",
Password: "", // no password set
DB: 0, // use default DB
})
coll := colly.NewCollector()
scrape := newScraper(coll, rc)
c := cron.New()
c.AddFunc("@every 10s", scrape.scrapePls)
c.Start()
sig := make(chan int)
<-sig
}
func (sc scraper) scrapePls() {
sc.coll.OnHTML(`body`, func(e *colly.HTMLElement) {
//Extracting required content
//Using Redis to store data
})
sc.coll.OnRequest(func(r *colly.Request) {
log.Println("Visting", r.URL)
})
sc.coll.Visit("www.example.com")
}
มันดูเหมือนว่าจะไม่ทำงานอยู่ทำให้การโทรครั้งนึงและไม่เป็นบางครั้งต่อเมื่อต้องทำต่อไปโทรมา ไม่แน่ใจว่าฉันพลาดอะไรบางอย่าง มันมีอีกซักคนเข้าใกล้ที่จะได้หรือยัง?
ที่เขาแนะนำให้ผูกผ้ากันเปื้อนจะเป็นเกียรติอย่างยิ่ง
ขอบคุณ!
{1 {30s} 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC 0x6efa80 0x6efa80}]
. ไม่ได้ช่วยสำหรับฉัน พอจะช่วยได้ไหม?