func SectorsToYaml(yamlFile string) (err error) {
	progress := []string{"/", "-", "\\", "|", "-", "\\"}
	var p int32
	if !overwritePrompt(yamlFile) {
		return rapina.ErrFileNotUpdated
	}
	f, err := os.Create(yamlFile)
	if err != nil {
		return errors.Wrapf(err, "falha ao criar arquivo %s", yamlFile)
	}
	defer f.Close()
	w := bufio.NewWriter(f)
	c := colly.NewCollector(
		colly.AllowURLRevisit(),
		colly.Async(false),
		colly.CacheDir(".data/cache"),
	)
	c.OnHTML("tr", func(e *colly.HTMLElement) {
		var sector string
		var subsectors []string
		c := 0
		e.ForEach("td", func(_ int, elem *colly.HTMLElement) {
			elem.DOM.Each(func(_ int, s *goquery.Selection) {
				h, _ := s.Html()
				if c == 0 {
					sector = h
					fmt.Fprintln(w, "  - Setor:", sector)
					fmt.Fprintln(w, "    Subsetores:")
				} else if c == 1 {
					subsectors = strings.Split(h, "<br/>")
					last := subsectors[0]
					for i := range subsectors {
						if subsectors[i] == "" {
							subsectors[i] = last
						}
						last = subsectors[i]
					}
				}
				c++
			})
			lastSub := ""
			elem.ForEach("a[href]", func(i int, elem *colly.HTMLElement) {
				if strings.Contains(elem.Attr("href"), "BuscaEmpresaListada.aspx") {
					if subsectors[i] != lastSub {
						fmt.Fprintln(w, "      - Subsetor:", subsectors[i])
						fmt.Fprintln(w, "        Segmentos:")
					}
					lastSub = subsectors[i]
					fmt.Fprintln(w, "          - Segmento:", elem.Text)
					fmt.Fprintln(w, "            Empresas:")
					_ = companies(w, "http://bvmf.bmfbovespa.com.br/cias-listadas/empresas-listadas/"+elem.Attr("href"))
				}
				fmt.Printf("\r[%s]", progress[p%6])
				p++
			})
		})
	})
	fmt.Print("[ ] Lendo informações do site da B3")
	fmt.Fprintln(w, "Setores:")
	err = c.Visit("http://bvmf.bmfbovespa.com.br/cias-listadas/empresas-listadas/BuscaEmpresaListada.aspx?opcao=1&indiceAba=1&Idioma=pt-br")
	fmt.Println()
	w.Flush()
	return
}
SectorsToYaml grab data from B3 website and prints out to a yaml file
with all companies grouped by sector, subsector, segment
package parsers
import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
	"github.com/PuerkitoBio/goquery"
	"github.com/dude333/rapina"
	"github.com/gocolly/colly"
	"github.com/pkg/errors"
	yaml "gopkg.in/yaml.v2"
)