I try scrape the description from website
img, but I not understand how to get there
My trying
pg := Program{}
slPG := []Program{}
c.OnHTML(".short", func(e *colly.HTMLElement) {
pg.Name = e.ChildText("h2.short-cat")
pg.Link = e.ChildAttr("a", "href")
pg.Rating = e.ChildText("a.orating_res")
pg.Discription = e.ChildText("div.short-text full-text video-box clearfix")
slPG = append(slPG, pg)
})
for i := 1; i < 6; i {
c.Visit("https://rsload.net/page/" strconv.Itoa(i) "/")
}
file, err := json.MarshalIndent(slPG, "", " ")
if err != nil {
log.Println("Unable to create 'json' file")
return
}
_ = ioutil.WriteFile("files/Export.json", file, 0644)
CodePudding user response:
Please show more of your code. Specifically, you need to show the part of the html which you are trying to grab. I know you have a part of the text and attributes, but the colly library is very picky. If you don't have exactly the right info. It will return nothing back to you. Are you getting the information back via fmt in command line, or parsing it into a gui, or perhaps converting it all into a file? Provide more info and we can help.
CodePudding user response:
Need write words before "sapce"
Exemple:
e.ChildText("div.short-text")