Files
bitburner-src/markdown/bitburner.ns.wget.md
Michael Ficocelli 6073964768 DARKNET: Darkweb Expansion Project & Bitnode (#2139)
This is BN15. It is a really big change; see the PR for all the details.
2026-02-03 03:40:36 -08:00

102 lines
1.5 KiB
Markdown

<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [wget](./bitburner.ns.wget.md)
## NS.wget() method
Download a file from the internet.
**Signature:**
```typescript
wget(url: string, target: string, host?: string): Promise<boolean>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
url
</td><td>
string
</td><td>
URL to pull data from.
</td></tr>
<tr><td>
target
</td><td>
string
</td><td>
Filename to write data to. Must be script or text file.
</td></tr>
<tr><td>
host
</td><td>
string
</td><td>
_(Optional)_ Optional hostname/ip of server for target file.
</td></tr>
</tbody></table>
**Returns:**
Promise&lt;boolean&gt;
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, .css). 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
```js
await ns.wget("https://raw.githubusercontent.com/bitburner-official/bitburner-src/master/README.md", "game_readme.txt");
```