zoukankan      html  css  js  c++  java
  • 看源码,弄清楚各个结构体

    https://github.com/PuerkitoBio/goquery#api


    package main

    import (
    "fmt"
    "log"
    "net/http"

    "github.com/PuerkitoBio/goquery"
    )
    /*
    <ul class="app-news-detail__meta"><li class="app-news-detail__meta-item">2018-08-30 11:54:44</li><!----></ul>
    document.getElementsByClassName("app-news-detail__meta-item").length = 1

    */
    func ExampleScrape() {
    // Request the HTML page.
    res, err := http.Get("http://cn.sonhoo.com/wukong/a182281")
    if err != nil {
    log.Fatal(err)
    }
    defer res.Body.Close()
    if res.StatusCode != 200 {
    log.Fatalf("status code error: %d %s", res.StatusCode, res.Status)
    }

    // Load the HTML document
    doc, err := goquery.NewDocumentFromReader(res.Body)
    if err != nil {
    log.Fatal(err)
    }

    // Find the review items
    doc.Find(".app-news-detail__meta-item").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 ", i, band, title)
    // 目标值
    ii := s.Text()
    fmt.Println(ii)
    })
    // https://github.com/PuerkitoBio/goquery#api
    // 看源码,弄清楚各个结构体
    i := doc.Find(".app-news-detail__meta-item")
    for _, v := range i.Nodes {
    fmt.Println(v.FirstChild.Data)
    break
    }
    }

    func main() {
    ExampleScrape()
    }



  • 相关阅读:
    Django 2.1 配sql server 2008R2
    1.内网安全代理技术
    3.frp搭建socks5代理
    2.变量常量和注释
    1.域环境&工作组&局域网探针方案
    4.nps搭建socks5代理
    1.php介绍和安装
    2.内网安全隧道技术
    3.横向smb&wmi明文或hash传递
    5.域横向CobaltStrike&SPN&RDP
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9566416.html
Copyright © 2011-2022 走看看