- // goGetJpg
- package main
- import (
- "fmt"
- "github.com/PuerkitoBio/goquery"
- "io"
- "net/http"
- "os"
- )
- func main() {
- x, _ := goquery.NewDocument("http://www.fengyun5.com/Sibao/600/1.html")
- urls, _ := x.Find("#content img").Attr("src")
- res, _ := http.Get(urls)
- file, _ := os.Create("xxx.jpg")
- io.Copy(file, res.Body)
- fmt.Println("下载完成!")
- }
- //该片段来自于http://www.codesnippet.cn/detail/211020136529.html
来源: http://www.codesnippet.cn/detail/211020136529.html