Created
August 14, 2020 10:56
-
-
Save buroz/9208f21f8aeb41175541719e03f15a91 to your computer and use it in GitHub Desktop.
Download All Uzumaki Chapters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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