golang 爬虫

package main

//引入相应的包

import (    

            "fmt"   

             "log"    

             "github.com/PuerkitoBio/goquery"

    )

func main() {    

            GetJokes()

    }

func GetJokes() {   

         doc, err := goquery.NewDocument("https://www.jinse.com/xinwen")   

         if err != nil {      

                  log.Fatal(err)    

        }   

         doc.Find(".article-main div ol").Each(func(i int, s *goquery.Selection) {       

                 //title 标题       

                 out_title := s.Find("h3").Text()      

                 println("out_title:", out_title)            

                }

        )

}

你可能感兴趣的:(golang 爬虫)