Last active
July 5, 2017 23:40
-
-
Save visibletrap/eae7f090ed273e6d65ca0c0ad8a90d09 to your computer and use it in GitHub Desktop.
Digging through Laptop details api of https://notebookspec.com/. Requires https://github.com/dakrone/clj-http, https://github.com/clojure/data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns notebook.core | |
(:require [clj-http.client :as http] | |
[clojure.data.json :as json] | |
[clojure.string :as string])) | |
(set! *print-length* -1) | |
(def notebooks (json/read-str (:body (http/get "https://notebookspec.com/api/notebook")) | |
:key-fn keyword)) | |
(first notebooks) | |
(keys (first notebooks)) | |
(def intel (comp #(= % "INTEL") :cpu_type)) | |
(def price (comp #(<= % 30000) #(Double/parseDouble %) :nb_price)) | |
(defn weight [w] (comp #(< % w) #(Double/parseDouble %) :nb_weight)) | |
(def windows-os (comp #(string/starts-with? % "Windows") :nb_os)) | |
(def ram (comp #(string/includes? % "4 GB"))) | |
(def ssd (comp #(and (string/includes? % "SSD") (not (string/includes? % "128"))) :nb_harddisk)) | |
(def screen-size (comp #(>= % 13) #(Double/parseDouble %) :nb_screen_inch)) | |
(def no-acer (comp not #(= % "ACER") :nb_brand)) | |
(->> notebooks | |
(filter (every-pred intel | |
price | |
(weight 1.8) | |
windows-os | |
ram | |
ssd | |
no-acer | |
screen-size | |
)) | |
;(map #(select-keys % [:nb_mobility :nb_option_ultrabook :nb_chipset :nb_cpu :nb_graphic | |
; :nb_price_adv :nb_price_banana :nb_screen_inch :minicpu :nb_performance | |
; :nb_weight :nb_price :cpu_name :nb_value :nb_price_advice :nb_price_jib | |
; :nb_price_mask :cpu_group :nb_screen :nb_brand :nb_harddisk])) | |
;(map #(select-keys % [:nb_brand :nb_price :nb_weight :cpu_group :nb_harddisk])) | |
(sort-by :nb_weight) | |
(map (juxt :nb_brand :nb_class_detail :nb_weight :nb_screen_inch)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment