Skip to content

Instantly share code, notes, and snippets.

@buroz
Created August 14, 2020 10:56
Show Gist options
  • Save buroz/9208f21f8aeb41175541719e03f15a91 to your computer and use it in GitHub Desktop.
Save buroz/9208f21f8aeb41175541719e03f15a91 to your computer and use it in GitHub Desktop.
Download All Uzumaki Chapters
package main
import (
"fmt"
"github.com/PuerkitoBio/goquery"
"io/ioutil"
"net/http"
"os"
)
func main() {
for i := 1; i <= 20; i++ {
link := fmt.Sprintf("https://uzumaki-manga.com/manga/uzumaki-chapter-%d", i)
folderName := fmt.Sprintf("./uzumaki/chapter-%d", i)
if _, err := os.Stat(folderName); os.IsNotExist(err) {
os.MkdirAll(folderName, 0755)
}
resp, _ := http.Get(link)
doc, _ := goquery.NewDocumentFromReader(resp.Body)
doc.Find(".separator").Each(func(index int, item *goquery.Selection) {
fullFilePath := fmt.Sprintf("%v/%d.jpg", folderName, index)
linkTag := item.Find("a")
href, _ := linkTag.Attr("href")
fmt.Println(fullFilePath)
resp, _ := http.Get(href)
jpg, _ := ioutil.ReadAll(resp.Body)
ioutil.WriteFile(fullFilePath, jpg, 0644)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment