another chunk lol, it is functional already
authorjosuer08 <josuer08@gmail.com>
Wed, 10 Aug 2022 03:25:36 +0000 (23:25 -0400)
committerjosuer08 <josuer08@gmail.com>
Wed, 10 Aug 2022 03:25:36 +0000 (23:25 -0400)
go.mod
go.sum
menu.js [new file with mode: 0644]
scrapper [new file with mode: 0755]
scrapper.go

diff --git a/go.mod b/go.mod
index c1a72c7b8c80f9ba085c6a1dcc31862ae007b6b2..08b7a978fac6dacf58e7caec85f2f4d373c72b37 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module main
 go 1.12
 
 require (
-       github.com/gocolly/colly/v2 v2.1.0
-       github.com/rocketlaunchr/google-search v1.1.4 // indirect
-       golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
+       github.com/gocolly/colly/v2 v2.1.0 // indirect
+       github.com/pborman/getopt v1.1.0
+       github.com/rocketlaunchr/google-search v1.1.4
 )
diff --git a/go.sum b/go.sum
index dc61cb783d4f0086c3562915fb90375867a95667..8cb57f623ba85448fcf7c5f59a77c42818398181 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -20,6 +20,7 @@ github.com/antchfx/xpath v1.1.8/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNY
 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
@@ -48,10 +49,14 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
 github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/jawher/mow.cli v1.1.0/go.mod h1:aNaQlc7ozF3vw6IJ2dHjp2ZFiA4ozMIYY6PyuRJwlUg=
 github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
 github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
+github.com/pborman/getopt v1.1.0 h1:eJ3aFZroQqq0bWmraivjQNt6Dmm5M0h2JcDW38/Azb0=
+github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/rocketlaunchr/google-search v1.1.4 h1:11tA5CoeUjoNnvdyUMGwyuxzihbBRDhoEFXlMmPm0k4=
@@ -60,6 +65,7 @@ github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxT
 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/temoto/robotstxt v1.1.1 h1:Gh8RCs8ouX3hRSxxK7B1mO5RFByQ4CmJZDwgom++JaA=
 github.com/temoto/robotstxt v1.1.1/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
@@ -102,6 +108,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3
 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
diff --git a/menu.js b/menu.js
new file mode 100644 (file)
index 0000000..85aecce
--- /dev/null
+++ b/menu.js
@@ -0,0 +1,131 @@
+/////////////////////////////////////////////////\r
+//                Variables                    //\r
+/////////////////////////////////////////////////\r
+    var button = $('#dropdown-button')\r
+       var subMenu = $('#dropdown-menu')\r
+    var subMenuItem = $("#dropdown-menu li")\r
+    var searchButton = $('#search-button')\r
+    var searchBox = $('#search-box')\r
+    \r
+    \r
+$(window).resize(function(){\r
+       if ($(window).width() <= 750){  \r
+               searchButton.text("Search")\r
+        searchButton.append(' <i class="fal fa-search">'); \r
+       } else {\r
+        searchButton.text("")\r
+        searchButton.append(' <i class="fal fa-search">');\r
+    }\r
+});\r
+\r
+\r
+/////////////////////////////////////////////////\r
+//             Show Menu Toggle                //\r
+/////////////////////////////////////////////////\r
+$(function() {\r
+    button.click(function() {\r
+        subMenu.slideToggle(250, 'easeInOutQuint');\r
+    });\r
+});\r
+\r
+/////////////////////////////////////////////////\r
+//              Menu Selection                 //\r
+/////////////////////////////////////////////////\r
+$(function() {\r
+    // Check which sub menu item was clicked\r
+    subMenuItem.click(function() {\r
+        console.log($(this).text() + " clicked");                                       // Tell me which item was clicked.\r
+        button.text($(this).text());                                                    // Copy the text of the selected menu item to the button.\r
+        button.append(' <i class="fal fa-' + $(this).attr("value") + '">');             // Set the icon to match the text.\r
+        button.val($(this).text());                                                     // Set the value of the button to that of the text selected.\r
+        subMenu.slideToggle(250, 'easeInOutQuint');                                     // Hide menu after selection is made.\r
+    });\r
+});\r
+\r
+/////////////////////////////////////////////////\r
+//       Controls Enter Key for TextBox        //\r
+/////////////////////////////////////////////////\r
+$(document).ready(function() {\r
+  $('body').keypress(function(e) {\r
+    if (e.which == 13) {\r
+      searchButton.trigger('click');\r
+      console.log("search button clicked");\r
+    }\r
+  });\r
+});\r
+\r
+/////////////////////////////////////////////////\r
+//         Generates the search string         //\r
+/////////////////////////////////////////////////\r
+$(document).ready(function() {\r
+  searchBox.val("");\r
+  searchBox.focus();\r
+    \r
+  searchButton.click(function() {\r
+    var type = button.val();                                                            // Set the type valriable to the value of the button.\r
+    var query = searchBox.val();                                                        // Set the Query variable to the value of the text box.\r
+    var arr = new Array();                                                              // Create a new blank array.\r
+    var commonToAll = " -inurl:(jsp|pl|php|html|aspx|htm|cf|shtml) " +                  // This string is common to all searches.\r
+        "-inurl:(index_of|listen77|mp3raid|mp3toss|mp3drug|index_of|wall" +\r
+        "ywashis) intitle:\"index.of./\" ";\r
+    if (query[query.length - 1] == ',') {                                               // Check the length of the search term to see if there were\r
+      query = query.slice(0, -1)                                                            // multiple search terms used, then slice the string at\r
+    }                                                                                       // every comma.\r
+    arr = query.split(',');                                                                         \r
+    arr.push(',');\r
+    switch (type) {                                                                     // Compare the type that was set earlier with the cases below\r
+      case ("Video"):\r
+        {\r
+          var extensions = " (avi|mkv|mov|mp4|mpg|wmv)";\r
+          break;\r
+        }\r
+      case ("Audio"):\r
+        {\r
+          var extensions = " (ac3|flac|m4a|mp3|ogg|wav|wma) ";\r
+          break;\r
+        }\r
+      case ("Ebook"):\r
+        {\r
+          var extensions = " (CBZ|CBR|CHM|DOC|DOCX|EPUB|MOBI|ODT|PDF|RTF|txt)";\r
+          break;\r
+        }\r
+      case ("Pictures"):\r
+        {\r
+          var extensions = " (bmp|gif|jpg|png|psd|tif|tiff) ";\r
+          break;\r
+        }\r
+      case ("Software/Games"):\r
+        {\r
+          var extensions = " (apk|exe|iso|rar|tar|zip) ";\r
+          break;\r
+        }\r
+      case ("Compressed"):\r
+        {\r
+          var extensions = " (7z|bz2|gz|iso|rar|zip) ";\r
+          break;\r
+        }\r
+      default:\r
+        {\r
+          var extensions = " (avi|mkv|mov|mp4|mpg|wmv)";\r
+          break;\r
+        }\r
+    }\r
+    for (var i = 0; i < arr.length - 1; i++) {\r
+      if (arr[i] != "") {\r
+        var temp = arr[i];\r
+        var last;\r
+        temp = temp.replace(/[^\w\s]/gi, '');\r
+        if (temp != 0) {\r
+          last = temp.replace(/ /g, ".");\r
+        }\r
+        var goodinput = "intext:\"" + last + "\"";\r
+        var finalquery = goodinput + extensions + commonToAll;\r
+\r
+        var url = "https://www.google.com/search?q=" + encodeURIComponent(finalquery);\r
+        //alert(goodinput);\r
+        window.open(url, '_blank');\r
+      }\r
+\r
+    }\r
+  });\r
+});\r
diff --git a/scrapper b/scrapper
new file mode 100755 (executable)
index 0000000..1268fdc
Binary files /dev/null and b/scrapper differ
index b24f05d8362e8e4f8f5377cc3a14d7d987ed61c8..e0d9a093078b3e6b212ffd8a0e46a98b82b36ffc 100644 (file)
@@ -1,9 +1,11 @@
 package main
 
 import (
-    "context"
-    "fmt"
-    "github.com/rocketlaunchr/google-search"
+       "context"
+       "fmt"
+       "os"
+
+       "github.com/rocketlaunchr/google-search"
 )
 
 func main() {
@@ -13,9 +15,44 @@ func main() {
     CountryCode: "us",
     LanguageCode: "en",
     }
-    q:="Mr Robot"
+
+
+
     common:=" -inurl:(jsp|pl|php|html|aspx|htm|cf|shtml) -inurl:(index_of|listen77|mp3raid|mp3toss|mp3drug|index_of|wallywashis) intitle:\"index.of./\" "
-    returnLinks, err := googlesearch.Search(ctx, q, opts)
+
+    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
@@ -28,5 +65,4 @@ func main() {
         fmt.Println("*", result.URL)
 
     }
-    //fmt.Println(googlesearch.Search(ctx, "cars for sale in Toronto, Canada"))
 }