archlinux - 如何從命令列取得軟體包統計資料(使用計數)?

archlinux - 如何從命令列取得軟體包統計資料(使用計數)?

是否有任何命令列介面archlinux 軟體包使用統計?我看了看螞蟻pkgstats,找不到任何這樣的選項。

我想要這樣的東西:

$ statpkg kitty
1392: kitty
95: kitty-git
74: kitty-framework
8: kittypack-git

答案1

當您造訪連結到的頁面時,開啟瀏覽器的網路標籤(按Ctrl+ shift+c並前往網路標籤),然後重新整理。其中一個請求傳回 JSON 回應。右鍵單擊它並複製該網址,您可以使用它來下載資料。

curl然後,您可以使用和定義手動函數,awk如下所示:

statpkg(){ 
    curl -s "https://pkgstats.archlinux.de/package/datatables?draw=4&columns%5B0%5D%5Bdata%5D=pkgname&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=count&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=false&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=1&order%5B0%5D%5Bdir%5D=desc&start=0&length=25&search%5Bvalue%5D=$1&search%5Bregex%5D=false&_=1559313142337" | 
    awk 'BEGIN{RS="[{}]";FS="[\":]"} {if ($9) print $9": "$5}' 
}

用法範例:

$ statpkg awesome
2452: ttf-font-awesome
1913: awesome-terminal-fonts
1835: awesome
1347: otf-font-awesome
652: ttf-font-awesome-4
649: python-qtawesome
409: python2-qtawesome
368: otf-font-awesome-4
302: fontawesome.sty
101: plasma5-applet-awesome-widgets
75: awesome-terminal-fonts-git
65: awesome-themes-git
60: awesome-freedesktop-git
57: awesome-terminal-fonts-patched
54: awesome-git
48: otf-font-awesome-5-free
43: awesome-revelation-git
34: awesome-luajit-git
28: awesomebump
25: python-qtawesome-git
24: awesome-gnome
21: awesome-scratch-git
18: otf-fontawesome
15: awesome-cinnamon
15: blackarch-config-awesome

相關內容