On Saturday, 6 August 2016 at 19:06:34 UTC, Sebastiaan Koppe wrote:
- code.dlang.org has an api but doesn't provide an endpoint to retrieve all packages/version. Now I just scrape the site instead (thanks Adam for your dom implementation).

No endpoint but still possible in two steps. For example test this script:

import std.stdio;
import std.net.curl;
import std.json;
import std.format;

void main()
auto allRaw = get(`https://code.dlang.org/packages/index.json`);
    auto allJson = parseJSON(allRaw);
enum latestFmtSpec = `https://code.dlang.org/api/packages/%s/latest`;
    foreach(p; allJson.array)
        auto ver = get(latestFmtSpec.format(p.str));
        writeln(p.str, " ", ver);

To get the whole list with the json is faster than scrapping. To get the version will certainly be slower (even in paralell because of the get() for each package but it's cleaner since it uses the API.

Reply via email to