]> git.armaanb.net Git - bettersearch.git/commitdiff
Initial commit
authorArmaan Bhojwani <me@armaanb.net>
Sat, 27 Nov 2021 00:47:10 +0000 (19:47 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sat, 27 Nov 2021 00:47:10 +0000 (19:47 -0500)
LICENSE [new file with mode: 0644]
bettersearch.rkt [new file with mode: 0644]
blacklist.rkt [new file with mode: 0644]

diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..18ccf5b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2021 Armaan Bhojwani <me@armaanb.net>
+
+Permission to use, copy, modify, and distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
diff --git a/bettersearch.rkt b/bettersearch.rkt
new file mode 100644 (file)
index 0000000..81c6f53
--- /dev/null
@@ -0,0 +1,25 @@
+#lang racket
+
+(require json)
+(require net/url)
+
+(require "blacklist.rkt")
+
+(define engine (string->url
+                "https://search.trom.tf/search?q=facebook&format=json"))
+(define response (get-pure-port engine))
+(define json-raw (port->string response))
+(close-input-port response)
+
+(define json
+  (with-input-from-string
+    json-raw
+    (lambda ()
+      (read-json))))
+
+; Convert results to net/url format
+(for-each (lambda (i)
+           (define result-url (string->url (hash-ref i 'url)))
+           (unless (member (url-host result-url) blacklist)
+             (writeln (url-host result-url))))
+         (hash-ref json 'results))
diff --git a/blacklist.rkt b/blacklist.rkt
new file mode 100644 (file)
index 0000000..3791a38
--- /dev/null
@@ -0,0 +1,24 @@
+#lang racket
+
+(provide blacklist)
+
+(define blacklist
+  '(
+    ; social_media
+    "www.facebook.com"
+    "facebook.com"
+    "instagram.com"
+    "twitter.com"
+
+    ; "stackexchange"
+    "askubuntu.com"
+    "blogoverflow.com"
+    "mathoverflow.net"
+    "serverfault.com"
+    "stackapps.com"
+    "stackexchange.com"
+    "stackoverflow.com"
+    "superuser.com"
+    "tex-talk.net"
+    "thesffblog.com"
+    ))