简体   繁体   中英

Python: Nessus API not Downloading Report

I need help in downloading the report from Nessus API. In the current scenario, the command is running fine but instead of downloading the report file in csv format, it is throwing all the output in the console.

How can I download and save the file instead of getting the output on the console?

import requests

url = "https://tenable.com/scans/<scan_id>/export/<file_id>/download"

headers = {
    'accept': "application/json",
    'x-apikeys': "accessKey=key;secretKey=key"
}

response = requests.request("GET", url, headers=headers)

print(response.text)

save it to a file like this:

response = requests.request("GET", url, headers=headers)

with open('file.pdf', 'wb') as f:
    f.write(response.content)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM