I'm using go-colly
to scrape data from a webpage:
I'm unable to parse out the src image from this nested HTML element.
c.OnHTML(".result-row", func(e *colly.HTMLElement) {
qoquerySelection := e.DOM
fmt.Println(qoquerySelection.Find("img").Attr("src"))
...
This .result-row
works for a lot of things like:
link := e.ChildAttrs("a", "href")
and
e.ChildText(".result-price")
How can I get the nested image src
value?
If I understood correctly, my solution should manage your needs. First, let me present the code:
After selecting all of the images on the web page, you've to replace the icon format with the largest one (in our case
1200x900
). I saw these formats in ascript
tag present near the bottom of the page.The rest should be pretty straightforward. Let me know if this solves your issue or if you need something else, thanks!