E.g. I have request:
aapl since:2017-02-28 until:2017-03-02
I’m using next code:
async def search(self, request, terminator=None, text_preprocessor=None):
"""
Search for tweets
:param request: search request
:type request: str
:param terminator: function that'll return true to stop search
:type terminator: (list[(str, datetime.datetime, int)])->bool
:param text_preprocessor: function that preprocess tweet texts before cleaning
:type text_preprocessor: (str)->str
:return: pairs text-uid
:rtype: list[(str, datetime, int)]
"""
print(request)
async def nop(_):
return False
def text_nop(txt):
return txt
if terminator is None:
terminator = nop
if text_preprocessor is None:
text_preprocessor = text_nop
params = {
"q": request,
"count": 100,
}
statuses = []
while True:
response = await self.peony.api.search.tweets.get(**params)
new_statuses = list(map(
lambda status: (
TwitterClient._clean(text_preprocessor(status['text'])),
TwitterClient._time(status['created_at']),
status['user']['id'],
),
response["statuses"]))
statuses += new_statuses
if "search_metadata" in response and "next_results" in response["search_metadata"]:
params = TwitterClient._next_results_params(response["search_metadata"]["next_results"])
else:
break
if await terminator(new_statuses):
break
print(len(statuses))
return statuses
But it return empty result. And, of course - in twitter UI I see non-empty resutl for same request.
p.s. ok, I found that search api may not return results older then week.