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

Added code to parse JSON webpage #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions parseWebPage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Created in Python 3.6.5
# Justgo129
# May 10, 2018
# adapted from
'''
https://stackoverflow.com/questions/12965203/how-to-get-json-from-webpage-into-python-script
'''

import urllib.request, json

myUrl = "http://199.26.254.151:8080/mudrod-service/SearchVocab?concept=sst"

def parse(myUrl):
with urllib.request.urlopen(myUrl) as url:
data = json.loads(url.read().decode())
print(json.dumps(data, indent=4))

parse(myUrl)

# output:
# {
# "graph": {
# "ontology": [
# {
# "word": "sea surface temperature",
# "weight": 1.0
# },
# {
# "word": "ocean temperature",
# "weight": 1.0
# },
# {
# "word": "group high resolution sea surface temperature dataset",
# "weight": 0.89
# },
# (etc)...