wg
This commit is contained in:
parent
c8abf6fc61
commit
4764182d24
6
main.go
6
main.go
@ -64,9 +64,12 @@ func main() {
|
||||
|
||||
os.MkdirAll(*outputDir, os.ModePerm)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
c := colly.NewCollector()
|
||||
c.OnHTML("ul.pagination li:nth-last-child(2)", func(e *colly.HTMLElement) {
|
||||
lastPage, _ = strconv.Atoi(strings.TrimSpace(e.Text))
|
||||
wg.Done()
|
||||
})
|
||||
c.OnHTML("div.amw-listing-item:nth-child(1) a[href]", func(e *colly.HTMLElement) {
|
||||
href := e.Attr("href")
|
||||
@ -82,8 +85,10 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
wg.Add(1)
|
||||
url := "https://theanarchistlibrary.org/latest/1"
|
||||
c.Visit(url)
|
||||
wg.Wait()
|
||||
|
||||
newPages := 1
|
||||
|
||||
@ -332,7 +337,6 @@ func get(url string, timeout time.Duration) (content []byte, err error) {
|
||||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode == 404 {
|
||||
// fmt.Fprintln(os.Stderr, url+" NOT FOUND!")
|
||||
missing = append(missing, url)
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user