Newbie question – loop through CSV to parse website

Apologies, this question is likely a little more basic than you all are used to in this subreddit. I am very new to POSH, and only slightly more experienced with bash, but I can’t use that for this task. I am trying to achieve something which I feel is probably reasonably easy, but thus far I have been unable to get working:

I have a CSV with a field for numbers (although for this I think they can/should be treated as strings). I need to loop through the list and for each entry download http://www.tenable.com/plugins/index.php?view=single&id=<number>, then parse the content for CVE numbers (formatted CVE-xxxx-xxxx where x is a digit), and output them into a CSV as a key/value pair with the input entry as the key and the CVE number as the value.

Making this a little more complex is the fact that on some of the pages there may not be a CVE number, in which case the value should just be left null and some have multiple CVE numbers, in which case the highest number should be used.

I have been able to extract a CVE number, but not the highest one, from individual pages where I enter the whole URL instead of using the list, but I cannot work out how to get a for loop or similar working and bring it all together, along with how I can output it all into a new field in the CSV file (or a copy of it).

I have copied what I have so far in the link below. Any assistance to get it all working would be greatly appreciated.

http://pastebin.com/uU8RUgV9

submitted by /u/Get-PoshHelp
[link] [comments]

Leave a Reply