Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mining the Social Web, Second Edition #78

Open
agarwalkushal25 opened this issue Jul 9, 2014 · 3 comments
Open

Mining the Social Web, Second Edition #78

agarwalkushal25 opened this issue Jul 9, 2014 · 3 comments

Comments

@agarwalkushal25
Copy link

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.

@ptwobrussell
Copy link
Owner

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 notifications@github.com 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.

@Drlenita
Copy link

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

@ptwobrussell
Copy link
Owner

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 notifications@github.com 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
#78 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants