Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nltk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
nltk
Commits
c70b4681
Commit
c70b4681
authored
May 01, 2015
by
Ewan Klein
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'twitter' of github.com:nltk/nltk into twitter
parents
eb5ed23b
c5f3d795
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
nltk/twitter/twitterclient.py
+6
-3
No files found.
nltk/twitter/twitterclient.py
View file @
c70b4681
...
@@ -205,7 +205,7 @@ class Query(Twython):
...
@@ -205,7 +205,7 @@ class Query(Twython):
a comma-separated string.
a comma-separated string.
:rtype: json
:rtype: json
"""
"""
results
=
self
.
search
(
q
=
keywords
,
count
=
min
(
100
,
count
),
lang
=
lang
)
results
=
self
.
search
(
q
=
keywords
,
count
=
min
(
100
,
count
),
lang
=
lang
,
result_type
=
'recent'
)
count_from_query
=
results
[
'search_metadata'
][
'count'
]
count_from_query
=
results
[
'search_metadata'
][
'count'
]
if
self
.
handler
.
handle_chunk
(
results
[
'statuses'
])
==
False
:
if
self
.
handler
.
handle_chunk
(
results
[
'statuses'
])
==
False
:
return
return
...
@@ -215,10 +215,13 @@ class Query(Twython):
...
@@ -215,10 +215,13 @@ class Query(Twython):
dealing with twitter rate limits
dealing with twitter rate limits
'''
'''
while
count_from_query
<
count
:
while
count_from_query
<
count
:
max_id
=
results
[
'search_metadata'
][
'max_id'
]
# the max_id is also in the metadata results['search_metadata']['next_results'],
# but as part of a query and difficult to fetch. This is doing the equivalent
# (last tweet id minus one)
max_id
=
results
[
'statuses'
][
99
][
'id'
]
-
1
try
:
try
:
results
=
self
.
search
(
q
=
keywords
,
count
=
min
(
100
,
count
-
count_from_query
),
results
=
self
.
search
(
q
=
keywords
,
count
=
min
(
100
,
count
-
count_from_query
),
lang
=
lang
,
max_id
=
max_id
)
lang
=
lang
,
max_id
=
max_id
,
result_type
=
'recent'
)
except
TwythonRateLimitError
as
e
:
except
TwythonRateLimitError
as
e
:
print
(
"Waiting for 15 minutes -{0}"
.
format
(
e
))
print
(
"Waiting for 15 minutes -{0}"
.
format
(
e
))
time
.
sleep
(
15
*
60
)
# wait 15 minutes
time
.
sleep
(
15
*
60
)
# wait 15 minutes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment