Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Python to Access Web Data_Coursera_Extracting Data from JSON #13

Open
fairypp opened this issue Jul 13, 2016 · 0 comments
Open

Using Python to Access Web Data_Coursera_Extracting Data from JSON #13

fairypp opened this issue Jul 13, 2016 · 0 comments

Comments

@fairypp
Copy link
Owner

fairypp commented Jul 13, 2016

import json
import urllib


while True:
    url = raw_input('Enter location: ')
    if len(url) < 1 : break

    print 'Retrieving', url
    uh = urllib.urlopen(url)
    data = uh.read()
    print 'Retrieved',len(data),'characters'
    ##print data
    info = json.loads(data)
    comments = info["comments"]
    print 'Count:', len(comments)
    sum = 0
    for item in comments:
        sum = sum + item['count']
    print 'Sum:', sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant