X-Git-Url: https://git.josue.xyz/?p=hotformathCLI%2F.git;a=blobdiff_plain;f=hotformathCLI.go;fp=hotformathCLI.go;h=e0d9a093078b3e6b212ffd8a0e46a98b82b36ffc;hp=0000000000000000000000000000000000000000;hb=99bb072073cf514bcc21a8837ba735ec87c438d3;hpb=1c9b6316b3b72227972266b343d09a38a2322516 diff --git a/hotformathCLI.go b/hotformathCLI.go new file mode 100644 index 0000000..e0d9a09 --- /dev/null +++ b/hotformathCLI.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "fmt" + "os" + + "github.com/rocketlaunchr/google-search" +) + +func main() { + ctx := context.Background() + opts := googlesearch.SearchOptions{ + Limit: 3, + CountryCode: "us", + LanguageCode: "en", + } + + + + common:=" -inurl:(jsp|pl|php|html|aspx|htm|cf|shtml) -inurl:(index_of|listen77|mp3raid|mp3toss|mp3drug|index_of|wallywashis) intitle:\"index.of./\" " + + VIDEO:=" (avi|mkv|mov|mp4|mpg|wmv)" + AUDIO:=" (ac3|flac|m4a|mp3|ogg|wav|wma)" + EBOOK:=" (CBZ|CBR|CHM|DOC|DOCX|EPUB|MOBI|ODT|PDF|RTF|txt)" + PICTURES:=" (bmp|gif|jpg|png|psd|tif|tiff)" + SOFTWARE:=" (apk|exe|iso|rar|tar|zip)" + COMPRESSED:=" (7z|bz2|gz|iso|rar|zip)" + + // implement getModifier() + + modifier:="" + switch os.Args[1] { + case "-v": + modifier = VIDEO + case "-a": + modifier = AUDIO + case "-e": + modifier = EBOOK + case "-p": + modifier = PICTURES + case "-s": + modifier = SOFTWARE + case "-c": + modifier = COMPRESSED + default: + fmt.Println("Usage: scrapper -[flag] \"[your search]\"") + fmt.Println("flags = [a]udio [c]ompressed [e]book [p]ictures [s]oftware [v]ideo") + os.Exit(0) + } + + query := "intext:\"" + os.Args[2] + "\"" + common + modifier + + + returnLinks, err := googlesearch.Search(ctx, query, opts) + if err != nil { + fmt.Println("Something went wrong: ", err) + return + } + if len(returnLinks) == 0 { + fmt.Println("no results returned: ", returnLinks) + } + + for _, result := range returnLinks { + fmt.Println("*", result.URL) + + } +}