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

Mining the Social Web, Second Edition

Open agarwalkushal25 opened this issue 10 years ago • 3 comments

On pages 25-26, there is this code:

q = '#MentionSomeoneImportantForYou'

count = 100

search_results = twitter_api.search.tweets(q=q, count=count)

twitter_api is predefined and is working fine.

statuses = search_results['statuses']

for _ in range(5): print "Length of statuses", len(statuses) try: next_results = search_results['search_metadata']['next_results'] except KeyError, e: # No more results when next_results doesn't exist break

kwargs = dict([ kv.split('=') for kv in next_results[1:].split("&") ])

The last code throws an error that 'next_results' is not defined.

agarwalkushal25 avatar Jul 09 '14 08:07 agarwalkushal25

I may be missing something, but from briefly inspecting the code again, I'm having a hard time identifying how this could happen. If the code in the "try" block fails, then it should break you out of the loop, avoiding the line of code in question that references "next_results"

Are you sure that your indentation level is correct? I can't tell from what you pasted in if you're running the code from in the notebook as-is or if you've typed it in and may have inadvertently adjusted indent levels.

I can think about this some more, but just wanted to check back first on how you are executing the code.

On Jul 9, 2014, at 3:18 AM, agarwalkushal25 [email protected] wrote:

On pages 25-26, there is this code:

q = '#MentionSomeoneImportantForYou'

count = 100

search_results = twitter_api.search.tweets(q=q, count=count) #twitter_api is predefined and is working fine.

statuses = search_results['statuses']

for _ in range(5): print "Length of statuses", len(statuses) try: next_results = search_results['search_metadata']['next_results'] except KeyError, e: # No more results when next_results doesn't exist break

kwargs = dict([ kv.split('=') for kv in next_results[1:].split("&") ])

The last code throws an error that 'next_results' is not defined.

— Reply to this email directly or view it on GitHub.

ptwobrussell avatar Jul 09 '14 15:07 ptwobrussell

I am totally lost, in trying to install a virtual machine. I do not know how to get to the screen, I follow until you get to step three on installing code on gitclone and goblin. I do not know how you get to that screen and get that code to run. I have osX on Mac. I installed github Please help!!1

Drlenita avatar Sep 10 '14 14:09 Drlenita

The screen that you see there is called a terminal. If you are on OS X, you should have an app called Terminal that you can use for that, but if you have never worked on the command line ever before, it might be a bit awkward at first. Give it a shot and let me know if I can help further.

On Wed, Sep 10, 2014 at 9:35 AM, Drlenita [email protected] wrote:

I am totally lost, in trying to install a virtual machine. I do not know how to get to the screen, I follow until you get to step three on installing code on gitclone and goblin. I do not know how you get to that screen and get that code to run. I have osX on Mac. I installed github Please help!!1

— Reply to this email directly or view it on GitHub https://github.com/ptwobrussell/Mining-the-Social-Web/issues/78#issuecomment-55124072 .

ptwobrussell avatar Sep 10 '14 16:09 ptwobrussell