How to automate Qualys Scan download using python Script
Not as simple as it sounds.
Do you have the Scan ID?
So I have written many scripts to talk with Qualys.
You would basically need a script to do the following and Jeff Leggett will correct me if I am wrong.
List of finished scans within some time frame
for each scan
Download Scan by Ref/ID
So if you don't have something like this I think your better off doing a download at a time. If what I posted seems like something you need I can give you a rough example in CURL Commands/Powershell but I don't have an experience in Python yet.
So I wrote a script that does this, and you are right, it isn't as simple as it sounds.
What my script does is similar to your steps, but I also did some steps in order to create a scan report that was as close to the Scan report from the "Quick Actions" menu as possible.
If that is what is desired, you must first create a scan report template with the same settings as the report generated from "Quick Actions" I did some testing to get something close. Some of the sections were in different places(spoke to Qualys support and there was no way to rearrange these sections in PDFs), but it suited our needs.
Get the Scan Ref
Launch a scan report
Download scan report
There are various hangups when doing this, there's a limit on the number of reports that can be launched at once and some other issues I've run into.
I am using example python code “PyQual: Simple Python code for the Qualys API” from
In general, the python code works OK, I am able to launch SCAN using the API, and to generate report as explained in the python example code above, i.e. obtaining template_id - for my own scan based template - from the web interface.
My goal is to generate a scan report that was as close to the Scan report from the "Quick Actions" menu as possible.
The report I generate is not similar to the Scan report from the "Quick Actions".
You've mentioned above thet you managed to get something close.
Would you be able to share your knowledge and/or provide some info how to get there?
Sorry for taking a bit to reply, not sure if you have figured it out yet, but you should be able to find some more detailed instructions in the Readme of my Dev branch here:
QualysReporting/Readme.md at dev · dmwoods38/QualysReporting · GitHub
I went through each of the settings I picked for my report. Let me know if this works for you.
What you get from the Quick Actions menu is sorta a report. If you want a report similar to this you need to create a Report template based on host/scan. When you execute this report template it should ask you what scan to report on. Then you can turn on/off other features and graphics until you get what you want.
If you want to run this via API it is not an issue; you will need the scan reference to give as a required parameter to the report template.
If you need example I have some that I use in CURL all the time.
I haven't used Python with Qualys alot but the first place I would start is here: paragbaxi/qualysapi · GitHub next I would check out: Qualys/community · GitHub
Have done a LOT of work with this and there are a lot of API Limits that you need to look out for Jeff Leggett can probably tell you more but if your at the QSC in Vegas look me up and I can show you how I worked on some of these issues.
Maybe they will work for you as well.
FWIW, I refactored my code and put it on github, you can see if it would solve your issues dmwoods38/QualysReporting · GitHub
I also created a dockerfile for easy installation here: dmwoods38/QualysReportingDocker · GitHub.
It's still not amazing, but it does what I need it to.
Retrieving data ...