Skip to content

Instantly share code, notes, and snippets.

@dictav
Created May 31, 2014 03:58
Show Gist options
  • Save dictav/72c23a97a245cfd7ccfb to your computer and use it in GitHub Desktop.
Save dictav/72c23a97a245cfd7ccfb to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/PuerkitoBio/goquery"
"strings"
)
func main() {
url := "http://connpass.com/event/6370/participation/"
doc, err := goquery.NewDocument(url)
if err != nil {
panic("could not create document from url: " + url)
}
doc.Find("table").Each(func(_ int, s *goquery.Selection) {
s.Find("tr").Each(func(index int, row *goquery.Selection) {
header := row.Find("th")
if header.Length() > 0 {
fmt.Println("\n")
fmt.Println(strings.Join(strings.Fields(header.First().Text()), ""))
fmt.Println("----------------------")
} else {
user_name := row.Find("p.display_name a").Text()
socials := [3]string{"", "", ""}
row.Find("td.social a").Each(func(si int, social *goquery.Selection) {
attr, ok := social.Attr("href")
if ok {
socials[si] = attr
}
})
fmt.Println(index, user_name)
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment