Created
May 31, 2014 03:58
-
-
Save dictav/72c23a97a245cfd7ccfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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