-
Notifications
You must be signed in to change notification settings - Fork 0
/
maango.go
68 lines (61 loc) · 1.8 KB
/
maango.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"log"
"os"
"strconv"
"github.com/PuerkitoBio/goquery"
)
func MaangoScrape(ScrapyURL string, PageCount int) {
doc, err := goquery.NewDocument(ScrapyURL)
if err != nil {
log.Fatal(err)
}
// Find the Music collections
doc.Find("#dle-content .post-serial .img-serial .left-btn-play").Each(func(i int, s *goquery.Selection) {
// For each item found, get the band and title
MovieName := s.Find("a").Text()
MovieSingleURL, ok := s.Find("a").Attr("href")
if ok {
DownloadURL := GetDownloadURL(MovieSingleURL)
// If the download link not available the maango.me site generates a static ad URL, we are excluding it.
if DownloadURL != "http://newtemplates.ru/" {
fmt.Printf("%d. %s - %s\n", PageCount+i+1, MovieName, DownloadURL)
// write the whole body at once
f, err := os.OpenFile("output.txt", os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
panic(err)
}
defer f.Close()
if _, err = f.WriteString(DownloadURL); err != nil {
panic(err)
}
if _, err = f.WriteString("\n"); err != nil {
panic(err)
}
}
}
})
}
func GetDownloadURL(SingleItemURL string) string {
var DownloadURL string
doc, err := goquery.NewDocument(SingleItemURL)
if err != nil {
log.Fatal(err)
}
doc.Find(".moredl").Each(func(i int, s *goquery.Selection) {
// For each item found, get the download url
DownloadURL, _ = s.Find("a").Attr("href")
})
return DownloadURLF
}
func main() {
var BaseUrl = "http://www.maango.me"
var Language = "/hindi" // Set the language http://www.maango.me/hindi/
var Pages = "/page/"
// Set the PageCount limit to total available pages.
for PageCount := 1; PageCount <= 10; PageCount++ {
var QueryURL = BaseUrl + Language + Pages + strconv.Itoa(PageCount) + "/"
MaangoScrape(QueryURL, ((PageCount - 1) * 12))
}
}