(require "blacklist.rkt")
+(define (member-match? itm lst)
+ (ormap (lambda (i)
+ (regexp-match? (regexp i) itm))
+ lst))
+
+(define (get-results query)
(define engine (string->url
"https://search.trom.tf/search?q=facebook&format=json"))
(define response (get-pure-port engine))
(lambda ()
(read-json))))
-; Convert results to net/url format
+; Parse and filter results
+; TODO: replace this with tail-call recursion and return instead of printing
(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))))
+ (define result-title (hash-ref i 'title ""))
+ (define result-url (url-host (string->url (hash-ref i 'url ""))))
+ (define result-content (hash-ref i 'content ""))
+
+ (unless (member-match? result-url blacklist)
+ (writeln result-title)
+ (writeln result-url)
+ (writeln result-content)
+ (writeln "")
+
+ ))
(hash-ref json 'results))
+)