Skip to content

Commit

Permalink
Compatible with python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
steelywing committed Jun 9, 2014
1 parent 465b7ca commit 0daf6bf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# I don't want to hose feedly's servers, so don't run this script too much.

import urllib2
try:
import urllib2 as request
except ImportError:
from urllib import request

import json

interests = [
Expand Down Expand Up @@ -33,8 +37,11 @@
print('Retreiving {}, ({} / {})'.format(interest, i + 1, len(interests)))

url = 'http://feedly.com/v3/search/feeds?q='+interest+'&n=10000'
response = urllib2.urlopen(url)
results = json.load(response)['results']
# python 2 return str, python 3 return bytes
response = request.urlopen(url).read()
if isinstance(response, bytes):
response = response.decode('utf-8')
results = json.loads(response)['results']

all_interests[interest] = []

Expand All @@ -55,5 +62,3 @@

with open('sites.json', 'w') as output:
output.write(json.dumps(by_url))


0 comments on commit 0daf6bf

Please sign in to comment.