1
import urllib
import json


url = "http://www.cvedetails.com/json-feed.php?numrows=10&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec=0&opov=0&opcsrf=0&opfileinc=0&opgpriv=0&opsqli=0&opxss=0&opdirt=0&opmemc=0&ophttprs=0&opbyp=0&opginf=0&opdos=0&orderby=3&cvssscoremin=4"
response = urllib.urlopen(url)

data = json.loads(response.read())

for f in data:
    a = json.loads(f)[u'update_date'][u'summary']

I have a error :

line 13, in <module>
    a = json.loads(f)[u'update_date'][u'summary']

I want the summary of that json just for example because if i just print the f var in the for cycle everything is ok.

{u'update_date': u'2013-11-25', u'cve_id': u'CVE-2013-6868', u'exploit_count': u'0', u'summary': u'SAP Sybase Adaptive Server Enterprise (ASE) 15.0.3 before 15.0.3 ESD#4.3, 15.5 before 15.5 ESD#5.3, and 15.7 before 15.7 SP50 or 15.7 SP100 allows local users to obtain sensitive information via unspecified vectors.', u'url': u'http://www.cvedetails.com/cve/CVE-2013-6868/', u'publish_date': u'2013-11-23', u'cvss_score': u'7.8', u'cwe_id': u'200'}
{u'update_date': u'2013-11-25', u'cve_id': u'CVE-2013-6867', u'exploit_count': u'0', u'summary': u'Unspecified vulnerability in SAP Sybase Adaptive Server Enterprise (ASE) 15.7 before 15.7 SP50 or 15.7 SP100 allows remote attackers to cause a denial of service via unspecified vectors.', u'url': u'http://www.cvedetails.com/cve/CVE-2013-6867/', u'publish_date': u'2013-11-23', u'cvss_score': u'7.1', u'cwe_id': u'0'}
{u'update_date': u'2013-11-27', u'cve_id': u'CVE-2013-6866', u'exploit_count': u'0', u'summary': u'SAP Sybase Adaptive Server Enterprise (ASE) before 15.0.3 ESD#4.3, 15.5 before 15.5 ESD#5.3, and 15.7 before 15.7 SP50 or 15.7 SP100 allows remote authenticated users to execute arbitrary code via unspecified vectors, aka CR736689.', u'url': u'http://www.cvedetails.com/cve/CVE-2013-6866/', u'publish_date': u'2013-11-23', u'cvss_score': u'9.0', u'cwe_id': u'94'}

I feel its a basic error but i'm not seeing the flaw.

Well after some search i got the expected result but thanks for all the fast help heres the final code:

#cvedetails_parser.py
import urllib
import son


url = "http://www.cvedetails.com/json-feed.php?numrows=10&vendor_id=0&product_id=0&version_id=0&hasexp=0&opec=0&opov=0&opcsrf=0&opfileinc=0&opgpriv=0&opsqli=0&opxss=0&opdirt=0&opmemc=0&ophttprs=0&opbyp=0&opginf=0&opdos=0&orderby=3&cvssscoremin=4"
response = urllib.urlopen(url)

data = json.loads(response.read())

for f in data:
    print "Update Date:", f['update_date']
    print "CVE ID:", f['cve_id']
    print "Number of Exploits:", f['exploit_count']
    print "CVSS Score:", f['cvss_score']
    print "Publish Date: ", f['publish_date']
    print "Summary: ", f['summary']
    print "\n"
    print "--------------------------------"
    print "--------------------------------"
2
  • 2
    What are you expecting to get as the value of a? Commented Dec 3, 2013 at 22:15
  • i see the error is : print "Summary: ", f['summary'] and everything is ok Commented Dec 3, 2013 at 22:17

1 Answer 1

2

no need to call loads twice, after first call 'data' and hence its entries 'f' are also of type dict

for f in data:
    print f['update_date']
    print f['summary']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.