Rosetta Code/Rank languages by popularity: Difference between revisions
Rosetta Code/Rank languages by popularity (view source)
Revision as of 22:06, 6 May 2023
, 1 year agoUpdated the URLs. Added a test to extract the title as "Category:" may be missing. Updated the result.
(fixed second DownloadString) |
(Updated the URLs. Added a test to extract the title as "Category:" may be missing. Updated the result.) |
||
Line 3,116:
=={{header|Nim}}==
<syntaxhighlight lang="nim">import std/[Algorithm, httpclient, json, re, strformat, strutils
const
LangSite = "http://www.rosettacode.org/
CatSite = "http://www.rosettacode.org/
let regex = re"title=""Category:(.*?)"">.+?</a>.*\((.*) members\)"
Line 3,131:
proc add(langs: var seq[string]; fromJson: JsonNode) =
for entry in fromJson{"query", "categorymembers"}:
if title.startsWith("Category:"):
langs.add title[9..^1]
var client = newHttpClient()
Line 3,158 ⟶ 3,160:
</syntaxhighlight>
Output:
<pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 896 - Rust
32 893 - Lua
33 849 - PicoLisp
34 843 - F Sharp
35 824 - AutoHotkey
36 818 - Ring
37 793 - Delphi
38 785 - JavaScript
39 778 - Arturo
40 776 - XPL0
...</pre>
|