Last active
May 6, 2024 21:42
-
-
Save usametov/99b502759908f74cfe5a86acce3cc87c to your computer and use it in GitHub Desktop.
github stars
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
#!/usr/bin/env bb | |
(require '[babashka.http-client :as http]) | |
(require '[clojure.string :as s]) ;; | |
(require '[cheshire.core :as json]) ;; | |
(def auth-token (System/getenv "GITHUBAPI_AUTH_TOKEN")) | |
;;TODO: add param | |
(doseq [pageNum (range 48)] | |
(spit | |
(str "./stars" pageNum ".json") | |
(:body | |
(http/get (str "https://api.github.com/users/usametov/starred?per_page=100&page=" pageNum) | |
{:headers {"Content-Type" "application/json" | |
"Accept" "application/json" | |
"Authorization" (str "bearer " auth-token)}})))) | |
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
#!/usr/bin/env bb | |
(require '[babashka.http-client :as http]) | |
(def topics | |
["bug-bounty" "bugbounty" "bugbountytips" "api-pentest" "api-security" "api-sec" | |
"apisec" "api-hacking" "hacktoberfest" "security" "c2" "osint" "recon" "discovery" | |
"emails" "information-gathering" "reconnaissance" "redteam" "cobalt-strike" "subdomain-enumeration" | |
"evil-twin"]) | |
(def auth-token (System/getenv "GITHUBAPI_AUTH_TOKEN")) | |
(def page-size 30) | |
(defn build-query | |
[topic min-stars min-date page] | |
{"pushed:>" min-date | |
"stars:>" min-stars | |
:q (str "topic:" topic) | |
:page page}) | |
(defn build-headers | |
[auth-token] | |
{"Content-Type" "application/json" | |
"Accept" "application/json" | |
"Authorization" (str "bearer " auth-token)}) | |
(def headers (build-headers auth-token)) | |
(defn get-total-count | |
[topic] | |
(:total_count | |
(json/parse-string | |
(:body | |
(http/get | |
"https://api.github.com/search/repositories" | |
{:query-params (build-query topic 50 "2023-06-01" 0) | |
:headers headers})) true))) | |
(doseq [topic topics] | |
(let [total-count (get-total-count topic) | |
page-count (quot total-count page-size)] | |
(doseq [page (range 1 (inc page-count))] | |
(Thread/sleep 1000) | |
(spit (str "./topics/" topic page ".json") | |
(:body | |
(http/get | |
"https://api.github.com/search/repositories" | |
{:query-params (build-query topic 50 "2023-06-01" page) | |
:headers headers})))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment