Guide to Make Cat Viewer Program
All credit goes to Sysroot!
Making the .ns File
- Open the editor with
nano GetCat.ns
- Then paste the following code:
export async function main(ns) {
await ns.wget("https://api.thecatapi.com/v1/images/search", "json.txt");
var content = await ns.read("json.txt");
var url = JSON.parse(content)[0]["url"];
await ns.write(ns.args[0], <html><body><img src=\"${url}\"></img></body></html>
, "w");
};
- Make sure to save with Ctrl+B!
Using the File
- To get your cat images, simply run
run GetCat.ns img.txt; cat img.txt
- Alternatively, you can use a different file name to store the cat image.
Be the first to comment