Created
August 28, 2015 12:55
-
-
Save komly/b73d636c57c53c797aa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import json | |
| import shelve | |
| from urllib2 import urlopen | |
| URL = 'http://54.200.3.128/examples/api.php' | |
| DB_FILENAME = 'data.db' | |
| def get_unique(url, db_filename): | |
| result = [] | |
| db = shelve.open(DB_FILENAME) | |
| data = json.load(urlopen(URL)) | |
| for entry in data: | |
| if str(entry['link_id']) not in db: | |
| result.append(entry) | |
| db[str(entry['link_id'])] = True | |
| db.close() | |
| return result | |
| print(get_unique(URL, DB_FILENAME)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment