summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-11-26 19:47:10 -0500
committerArmaan Bhojwani <me@armaanb.net>2021-11-26 19:47:10 -0500
commit50fd113f77b184baada5ba0aba933ef76c83fbb9 (patch)
treebc80d0e1c4d985dc20c1709ff63a5910709a90c8
downloadbettersearch-50fd113f77b184baada5ba0aba933ef76c83fbb9.tar.gz
Initial commit
-rw-r--r--LICENSE13
-rw-r--r--bettersearch.rkt25
-rw-r--r--blacklist.rkt24
3 files changed, 62 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
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
index 0000000..81c6f53
--- /dev/null
+++ b/bettersearch.rkt
@@ -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
index 0000000..3791a38
--- /dev/null
+++ b/blacklist.rkt
@@ -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"
+ ))