ptwobrussell / Mining-the-Social-Web

The official online compendium for Mining the Social Web (O'Reilly, 2011)
http://bit.ly/135dHfs
Other
1.21k stars 491 forks source link

Example 1-3 fails with 404 errors #3

Closed edglazer closed 13 years ago

edglazer commented 13 years ago

Hello, I've done some searching on both this site, as well as the site for the twitter package (version 1.6.1), and the twitter API, but I'm unclear as to why this code fails to execute properly. I'm on Snow Leopard, using the Enthought python distribution (32-bit) with python 2.7.1, and entering the code in the IDLE shell. Executing the code results in the following error message:

Traceback (most recent call last): File "<pyshell#4>", line 1, in trends = twitter_search.trends() File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/twitter/api.py", line 153, in call return self._handle_response(req, uri, arg_data) File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/twitter/api.py", line 168, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) TwitterHTTPError: Twitter sent status 404 for URL: trends.json using parameters: () details: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

The page you were looking for doesn't exist (404)

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

##

My suspicion is that something has changed in how the search api handles trends, but I'm not very experienced with api's, so I may have misunderstood what the search api is supposed to be doing.

I began to raise the issue on an existing thread in the twitter package repository (https://github.com/sixohsix/twitter/issues/41#issuecomment-1017343) but as I said, I think this problem is separate from the one experienced there, involving the search api, and setting the api_version flag to None.

Any help, or even confirmation that its a change in how the twitter api is handling trends (thus suggesting I'm not an idiot), would be appreciated. Thanks!

edglazer commented 13 years ago

Also, as you're probably aware, Github parsing the error code from python and twitter changed the formatting a smidge, but the information is still there. Thanks!

ptwobrussell commented 13 years ago

Hey edglazer - Thanks for reporting this issue. I also got a related report from another reader and I've posted the details at https://github.com/ptwobrussell/Mining-the-Social-Web/wiki/Confirmed-Bugs-and-Errata for you to review. Check that out and let me know if it makes sense. In short, the domain for Twitter's trends API did change, so that's causing a little bit of short-term pain for readers. Unfortunately, there was no good way to anticipate this, but I still want to apologize for the inconvenience this is no doubt causing you and others. I plan to sift through Mining the Social Web example code and 21 Recipes for Mining Twitter code as early in the week as I can and get this all ironed out.

I won't close this issue until I'm confident that all of those things have happened and have been confirmed in GitHub source code example as well as with O'Reilly for reprint purposes.

edglazer commented 13 years ago

Hiya Matthew, thanks for the note, and for confirming my potential sanity. I looked at the errata through the wiki link you provide, and the suggested code change appears to fix the problems I was having. That's the challenge in working with some of these social media APIs, like hitting a barrel of monkeys attached to a moving target. Best.

umberto77 commented 12 years ago

HI russel, i've got the same error in example 1.3 precisely Traceback (most recent call last): File "/Users/macbook/Documents/web mining/twitter1", line 3, in trends=twitter_search.trends() File "build/bdist.macosx-10.5-fat3/egg/twitter/api.py", line 167, in call return self._handle_response(req, uri, arg_data) File "build/bdist.macosx-10.5-fat3/egg/twitter/api.py", line 182, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) TwitterHTTPError: Twitter sent status 404 for URL: trends.json using parameters: () details:

could you explainme what to do?

thanks

ptwobrussell commented 12 years ago

Does this gist help? https://gist.github.com/1592859

amejiarosario commented 11 years ago

I ran into the same problem. What happened it's that http://search.twitter.com/trends have been deprecated! So, I ended up using the new one is this: https://api.twitter.com/1/trends/1.json

derp-derpington commented 11 years ago

Hi All,

I face the same error with example 4_3 and 4_4. I cannot get any friends or followers using the twitter__util.py that you provided in the GitHub repository. I keep getting the error:

TwitterHTTPError: Twitter sent status 404 for URL: 1/trends.json using parameters: () ...................................

I read that Twitter made modifications to its API, so this maybe the reason. Could anybody help me out?

Thanks in advance!