1. XenForo 1.5.14 中文版——支持中文搜索!现已发布!查看详情
  2. Xenforo 爱好者讨论群:215909318 XenForo专区

新闻 goquery 1.1.0 发布,Go 语言的 HTML 解析器 下载

本帖由 漂亮的石头2017-03-11 发布。版面名称:软件资讯

  1. 漂亮的石头

    漂亮的石头 版主 管理成员

    注册:
    2012-02-10
    帖子:
    487,979
    赞:
    47
    goquery 1.1.0 发布了,该版本增加了 SetHtml 和 SetText 方法。

    goquery是一个使用go语言写成的HTML解析库,可以让你像jQuery那样的方式来操作DOM文档。

    示例代码:

    package main

    import (
    "fmt"
    "log"

    "github.com/PuerkitoBio/goquery"
    )

    func ExampleScrape() {
    doc, err := goquery.NewDocument("http://metalsucks.net")
    if err != nil {
    log.Fatal(err)
    }

    // Find the review items
    doc.Find(".sidebar-reviews article .content-block").Each(func(i int, s *goquery.Selection) {
    // For each item found, get the band and title
    band := s.Find("a").Text()
    title := s.Find("i").Text()
    fmt.Printf("Review %d: %s - %s\n", i, band, title)
    })
    }

    func main() {
    ExampleScrape()
    }
    goquery 1.1.0 发布,Go 语言的 HTML 解析器下载地址
     
正在加载...