Files
bitburner-src/markdown/bitburner.ns.wget.md

1.5 KiB

Home > bitburner > NS > wget

NS.wget() method

Download a file from the internet.

Signature:

wget(url: string, target: string, host?: string): Promise<boolean>;

Parameters

Parameter

Type

Description

url

string

URL to pull data from.

target

string

Filename to write data to. Must be script or text file.

host

string

(Optional) Hostname/IP of server for target file. Optional. Defaults to the server the calling script is running on.

Returns:

Promise<boolean>

True if the data was successfully retrieved from the URL, false otherwise.

Remarks

RAM cost: 0 GB

Retrieves data from a URL and downloads it to a file on the specified server. The data can only be downloaded to a script (.js, .jsx, .ts, .tsx) or a text file (.txt, .json). If the file already exists, it will be overwritten by this command. Note that it will not be possible to download data from many websites because they do not allow cross-origin resource sharing (CORS).

Example

await ns.wget("https://raw.githubusercontent.com/bitburner-official/bitburner-src/master/README.md", "game_readme.txt");