Skip to content

Instantly share code, notes, and snippets.

@hiredman
Last active March 30, 2018 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiredman/7b13eb5dcc4fe0ae03ef91d62f66ec2d to your computer and use it in GitHub Desktop.
Save hiredman/7b13eb5dcc4fe0ae03ef91d62f66ec2d to your computer and use it in GitHub Desktop.
#!/bin/bash
#_ (
true;exec java -jar /home/kevin/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar $0
)
(let [pom-uber-jar (str "http://thelibraryofcongress.s3.amazonaws.com/"
"pomegranate-0.3.1-SNAPSHOT-jar-with-dependencies.jar")]
(.addURL @clojure.lang.Compiler/LOADER (java.net.URL. pom-uber-jar))
(require '[cemerick.pomegranate :as pom])
((resolve 'pom/add-dependencies)
:coordinates '[[net.sourceforge.htmlunit/htmlunit "2.19"]]
:repositories (merge @(resolve 'cemerick.pomegranate.aether/maven-central)
{"clojars" "http://clojars.org/repo"})))
(import '(com.gargoylesoftware.htmlunit WebClient))
(def services
'[[IAM iam]
[AWSEC2 ec2]
[AmazonECS ecs]
[AmazonRDS rds]
[amazondynamodb dynamodb]
[AmazonElastiCache elasticache]
[AutoScaling autoscaling]
[AmazonCloudWatch cloudwatch]])
(with-open [wc (doto (WebClient.)
(-> (.getOptions)
(.setJavaScriptEnabled false)))]
(letfn [(action-scraper1 [service-name prefix]
(-> (.getPage wc (format "https://docs.aws.amazon.com/%s/latest/APIReference/API_Operations.html"
service-name))
(.getByXPath "//div[@id='content-container']")
(first)
(.getByXPath "//a[@class='xref']")
(->> (map #(.getValue (get (.getAttributesMap %) "title")))
(map (partial str prefix ":"))
(vec))))]
(prn
(reduce
(fn [actions [service-name prefix]]
(Thread/sleep 1000)
(into actions (action-scraper1 (name service-name) (name prefix))))
[]
services))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment