Commit 1d29b9a6 authored by Sacha's avatar Sacha
Browse files

see diff

parent de184084
......@@ -170,8 +170,10 @@ def article_search(keyword, training=False):
'facet_field': 'source'
})
tor_query.renew_connection()
response = tor_query.query('%s%s' % (ARTICLE_SEARCH_BASE, params))
#tor_query.renew_connection()
#response = tor_query.query('%s%s' % (ARTICLE_SEARCH_BASE, params))
response = urllib2.urlopen('%s%s' % (ARTICLE_SEARCH_BASE, params))
# an Article will be None if it doesn't have body text (thus the partial)
# return an array of Article objects that have a body text
parsed_response = json.loads(response.read())['response']['docs']
......@@ -197,10 +199,11 @@ def article_comments(url, offset=0, training=False):
})
try:
response = tor_query.query('%s%s' % (COMMENT_BASE, params))
#response = tor_query.query('%s%s' % (COMMENT_BASE, params))
response = urllib2.urlopen('%s%s' % (COMMENT_BASE, params))
except urllib2.HTTPError:
# max requests exceeded (>5k queries or >30 / second)
tor_query.renew_connection()
#tor_query.renew_connection()
curr_key += 1
i -= 1
break
......
......@@ -16,7 +16,6 @@ def perform(keyword, training=False):
"""Provide ``keyword`` for content retrieval, scoring.
"""
articles = article_search(keyword, training=training)
print('here')
if len(articles) == 0:
raise UsageError('no-articles', status_code=200)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment