Bitburner – How to Make Cat Viewer Program

Guide to Make Cat Viewer Program

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.

Recommended for You

Be the first to comment

Leave a Reply

Your email address will not be published.


*