Permalink
Browse files

Unquote Twitter API responses to address URL encoding error

1 parent b2b3fad commit a532e3597f05bd13a4457bcbe265039648a6291a @mbfhunzaker mbfhunzaker committed Jan 15, 2015
@@ -182,6 +182,9 @@
"cell_type": "code",
"collapsed": false,
"input": [
+ "# Import unquote to prevent url encoding errors in next_results\n",
+ "from urllib import unquote\n",
+ "\n",
"# XXX: Set this variable to a trending topic, \n",
"# or anything else for that matter. The example query below\n",
"# was a trending topic when this content was being developed\n",
@@ -209,7 +212,7 @@
" \n",
" # Create a dictionary from next_results, which has the following form:\n",
" # ?max_id=313519052523986943&q=NCAA&include_entities=1\n",
- " kwargs = dict([ kv.split('=') for kv in next_results[1:].split(\"&\") ])\n",
+ " kwargs = dict([ kv.split('=') for kv in unquote(next_results[1:]).split(\"&\") ])\n",
" \n",
" search_results = twitter_api.search.tweets(**kwargs)\n",
" statuses += search_results['statuses']\n",
@@ -1210,6 +1210,9 @@
"cell_type": "code",
"collapsed": false,
"input": [
+ "# Import unquote to prevent url encoding errors in next_results\n",
+ "from urllib import unquote\n",
+ "\n",
"# XXX: Set this variable to a trending topic, \n",
"# or anything else for that matter. The example query below\n",
"# was a trending topic when this content was being developed\n",
@@ -1237,7 +1240,8 @@
" \n",
" # Create a dictionary from next_results, which has the following form:\n",
" # ?max_id=313519052523986943&q=NCAA&include_entities=1\n",
- " kwargs = dict([ kv.split('=') for kv in next_results[1:].split(\"&\") ])\n",
+ " kwargs = dict([kv.split('=') for kv in unquote(next_results[1:]).split(\"&\") ]) \n",
+ "\n",
" \n",
" search_results = twitter_api.search.tweets(**kwargs)\n",
" statuses += search_results['statuses']\n",

0 comments on commit a532e35

Please sign in to comment.