Ejemplo n.º 1
0
func main() {
	flag.Parse()
	filesChan := make(chan string)

	go webdevdata.GetFiles(filesChan, 0)
	csv := csv.NewWriter(os.Stdout)

	for file := range filesChan {
		tags := make(map[string]int)
		webdevdata.ProcessTags(file, func(token html.Token) {
			tags[token.Data]++
		})

		for tag, count := range tags {
			csv.Write([]string{file, tag, strconv.Itoa(count)})
		}
	}
	csv.Flush()
}
Ejemplo n.º 2
0
func main() {
	attrs := flag.String("attrs", "", "CSV list of attributes to print")
	flag.Parse()

	if flag.NArg() == 0 {
		fmt.Fprintln(os.Stderr, "You need to provide a CSS selector and one file")
		os.Exit(-1)
	}

	selector := flag.Arg(0)
	filesChan := make(chan string)

	go webdevdata.GetFiles(filesChan, 1)

	attrList := regexp.MustCompile(",").Split(*attrs, -1)
	csv := csv.NewWriter(os.Stdout)

	for file := range filesChan {
		process(file, selector, attrList, csv)
	}

	csv.Flush()
}