while ( = for ) loop

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

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

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

    count := 0
    var title string
    var ta_url string
    ta_url = url
    var flag bool = true

    for flag == true {
        flag = false

        doc, err := goquery.NewDocument(ta_url)
        if err != nil {
            panic("query failed.")
        }

        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`)

        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
    }
}
Edit
Pub: 15 May 2022 06:21 UTC
Edit: 18 May 2022 13:55 UTC
Views: 232