recursive

//go get github.com/PuerkitoBio/goquery
package main

import (
    "fmt"
    "log"
    "github.com/PuerkitoBio/goquery"
    "regexp"
)

func recursive(count int,ta_url string) (int,string) {
        var flag bool = false

        doc, err := goquery.NewDocument(ta_url)
        if err != nil {
            log.Println("err",err)
        }

        atag := doc.Find("a")
        re1 := regexp.MustCompile(`^Home`)
        re2 := regexp.MustCompile(`^Popular Manga`)
        re3 := regexp.MustCompile(`^Page\s\d*`)
        re4 := regexp.MustCompile(`^Prev`)
        re5 := regexp.MustCompile(`^Newest`)
        re0 := regexp.MustCompile(`^Next`)

        var title string
        atag.Each(func(i int, s *goquery.Selection){
            str1, _ := s.Attr("title")
            str2, _ := s.Attr("href")
            title = str1
            if re0.MatchString(title) {
                ta_url = str2
                flag = true
            } else if ( title == "" || re1.MatchString(title) == true || re2.MatchString(title) == true || re3.MatchString(title) == true || re4.MatchString(title) == true || re4.MatchString(title) == true || re5.MatchString(title) == true ) {
            } else {
                count ++
                fmt.Println(count, title)
            }
        })

        atag = nil
        doc = nil

        if flag != true {
            return 1,"end"
        } else {
            return recursive(count,ta_url)
        }
}

func main() {
    url := "https://13dl.me/list/popular/"

    count := 0
    var ta_url string
    ta_url = url

    recursive(count,ta_url)
}
Edit
Pub: 17 May 2022 11:32 UTC
Edit: 18 May 2022 13:53 UTC
Views: 164