I have a web scraper and I need to write a string from HTML code to my CSV file. The HTML code looks like this:
<div class="qa-static-ad-map-container">
<img src="/app/static/media/staticmap.65e20ad98.svg" alt="Bucuresti - Ilfov, Bucuresti,
Sectorul 4" class="css-149mw5z">
</div>
I have to somehow get the text in the alt attribute; This is the code I've written:
c.OnHTML(".qa-static-ad-map-container img", func(e *colly.HTMLElement) { //class that contains wanted info
writer.Write([]string{
e.Attr("alt"),
})
})
It doesn't give any error and also shows me that the onHtml request has been made, but nothing is written in the file.