Mining-the-Social-Web icon indicating copy to clipboard operation
Mining-the-Social-Web copied to clipboard

Example 1.3 (1st Edition)

Open kimskams80 opened this issue 11 years ago • 3 comments

With reference to your reply on https://github.com/ptwobrussell/Mining-the-Social-Web/issues/15#issuecomment-22006680 I am starting a new thread here for example 1.3. It must be noted that I am using 1st edition of this book with Python 2.7.2. This example is on Page 5 of this book.

example:

import twitter twitter_search = twitter.Twitter(domain="search.twitter.com") trends = twitter_search.trends() [ trend['name'] for trend in trends['trends'] ]

First two lines go well but when I type

trends = twitter_search.trends()

it gives following error:

Traceback (most recent call last): File "(stdin)" line 1 in File "build\bdist.win-amd64\egg\twitter\api.py" line 204 in call File "build\bdist.win-amd64\egg\twitter\api.py" line 235 in _handle_response

twitter.api.TwitterHTTPErro"Twitter sent status 410 for URL : 1.1/trends.json using parameters :()

details: {"errors": [{message":The twitter REST API v1 is no longer active. Please migrate to API 1.1. https://dev.twitter.com/docs/api/1.1/overview. code:68}]

A bonus question please: How can I clear the screen of Python Interactive Shell?

kimskams80 avatar Aug 06 '13 06:08 kimskams80

Thanks for such a detailed report. The basic problem is that Twitter did indeed change the way that their API worked as indicated by the error message, and you can get updated code for Chapter 1 here: http://nbviewer.ipython.org/urls/raw.github.com/ptwobrussell/Mining-the-Social-Web/master/ipython_notebooks/Chapter1.ipynb

Specifically, see Example 1-3 in that notebook for an updated version of the code that should work for you. Since the code related to Twitter that's in the text of the book will be outdated, be sure to reference the other notebooks from here https://github.com/ptwobrussell/Mining-the-Social-Web#update---march-2013 when exploring those examples. The example files checked into this repository as individual .py files are also updated (but Example 1-3 is an interactive session and not a .py file.)

Let me know if this helps you. I'd really like to see you get past this problem and start having some fun with this.

Also, you may want to consider watching this screencast if you'd like to start using IPython Notebook and the virtual machine, which is part of the second edition: https://www.youtube.com/watch?v=BTyKPMfi_JQ

As for your question - how do you clear the session in an interpreter - you might want to review this SO response - http://stackoverflow.com/questions/517970/how-to-clear-python-interpreter-console

However, I would strongly encourage you to consider using IPython. It's a much better shell that provides lots of enhancements that you will surely benefit from - http://ipython.org/install.html

ptwobrussell avatar Aug 06 '13 10:08 ptwobrussell

Hi @kimskams80 e @ptwobrussell, I'm four days searching for the answer to this error API and only now I see it. Congratulations kimskams80 to the question and the master Russell, for the answer. thank you!

Baco23 avatar Feb 02 '15 20:02 Baco23

@ptwobrussell Thanks a lot for the updates! This helps!

jianjinucdavis avatar Aug 21 '15 02:08 jianjinucdavis