<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          goqueryGo 的 HTML/XML 解析庫

          聯(lián)合創(chuàng)作 · 2023-09-21 23:41

          goquery是一個(gè)使用go語言寫成的HTML解析庫,可以讓你像jQuery那樣的方式來操作DOM文檔。下面是示例:

          func ExampleScrape_MetalReview() {
            // Load the HTML document (in real use, the type would be *goquery.Document)
            var doc *Document
            var e error
          
            if doc, e = NewDocument("http://metalreview.com"); e != nil {
              panic(e.Error())
            }
          
            // Find the review items (the type of the Selection would be *goquery.Selection)
            doc.Find(".slider-row:nth-child(1) .slider-item").Each(func(i int, s *Selection) {
              var band, title string
              var score float64
          
              // For each item found, get the band, title and score, and print it
              band = s.Find("strong").Text()
              title = s.Find("em").Text()
              if score, e = strconv.ParseFloat(s.Find(".score").Text(), 64); e != nil {
                // Not a valid float, ignore score
                fmt.Printf("Review %d: %s - %s.\n", i, band, title)
              } else {
                // Print all, including score
                fmt.Printf("Review %d: %s - %s (%2.1f).\n", i, band, title, score)
              }
            })
          瀏覽 13
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  人妻喷水 | 五月天婷婷丁香综合性爱网 | 人人妻人人上 | 午夜理理伦电影A片无码蜜桃av | 成A人视频 |