Created
November 13, 2019 05:43
-
-
Save datsuns/be47c5f9a2193a4852771d3c7bd39482 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" | |
"os" | |
) | |
func LoadPage(path string) { | |
f, err := os.Open(path) | |
if err != nil { | |
panic(err) | |
} | |
doc, err := goquery.NewDocumentFromReader(f) | |
if err != nil { | |
panic(err) | |
} | |
doc.Find("div#f > div#l> div#s").Each(func(_ int, s *goquery.Selection) { | |
s.Find("tbody > tr > td").Each(func(_ int, s *goquery.Selection) { | |
fmt.Println(s.Html()) | |
}) | |
}) | |
} | |
func GetPage(url string) { | |
doc, _ := goquery.NewDocument(url) | |
doc.Find("div id='s'").Each(func(_ int, s *goquery.Selection) { | |
//url, _ := s.Attr("href") | |
//fmt.Println(doc) | |
fmt.Println(s) | |
}) | |
fmt.Println(doc) | |
} | |
func main() { | |
//url := "http://qiita.com/advent-calendar/2013/" | |
//url := "https://xn--eckfza0gxcvmna6c.gamerch.com/%E4%B8%80%E5%A4%A9%E5%9B%9B%E6%B5%B7%E3%83%8E%E5%A4%A9%E9%AD%94%E3%83%92%E3%82%B6%E3%83%AB%E3%83%93%E3%83%B3" | |
//GetPage(url) | |
LoadPage("./dat.html") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment