В [115]: twitter_stream.filter (track = senators_df.TwitterHandle.tolist (), follow = senators_df.TwitterID.tolist ())
Успешно подключено к Твиттеру
OperationFailure Traceback (последний вызов был последним) в ----> 1 twitter_stream.filter (track = senators_df.TwitterHandle.tolist (), follow = senators_df.TwitterID.tolist ())
~ / anaconda3 / lib / python3 .7 / site-packages / tweepy / streaming.py в фильтре (self, follow, track, is_asyn c, местоположения, предупреждения о стойле, языки, кодировка, filter_level)
472 self.body['filter_level'] = filter_level.encode(encoding)
473 self.session.params = {'delimited': 'length'}
--> 474 self._start(is_async)
475
476 def sitestream(self, follow, stall_warnings=False,
~ / anaconda3 /lib/python3.7/site-packages/tweepy/streaming.py в _start (self, is_asyn c)
387 self._thread.start()
388 else:
--> 389 self._run()
390
391 def on_closed(self, resp):
~/anaconda3/lib/python3.7/site-packages/tweepy/streaming.py in _run(self)
318 # call a handler first so that the exception can be logged.
319 self.listener.on_exception(exc_info[1])
--> 320 six.reraise(*exc_info)
321
322 def _data(self, data):
~/anaconda3/lib/python3.7/site-packages/six.py in reraise(tp, value, tb)
691 if value.__traceback__ is not tb:
692 raise value.with_traceback(tb)
--> 693 raise value
694 finally:
695 value = None
~/anaconda3/lib/python3.7/site-packages/tweepy/streaming.py in _run(self)
287 self.snooze_time = self.snooze_time_step
288 self.listener.on_connect()
--> 289 self._read_loop(resp)
290 except (Timeout, ssl.SSLError) as exc:
291 # This is still necessary, as a SSLError can actually be
~/anaconda3/lib/python3.7/site-packages/tweepy/streaming.py in _read_loop(self, resp)
349 next_status_obj = buf.read_len(length)
350 if self.running and next_status_obj:
--> 351 self._data(next_status_obj)
352
353 # # Note: keep-alive newlines might be inserted before each length value.
~/anaconda3/lib/python3.7/site-packages/tweepy/streaming.py in _data(self, data)
321
322 def _data(self, data):
--> 323 if self.listener.on_data(data) is False:
324 self.running = False
325
~/Documents/Software_Development/Trainings/Python/PythonFundamentalsCode/ch16/tweetlistener.py in on_data(self, data)
24 self.tweet_count += 1 # track number of tweets processed
25 json_data = json.loads(data) # convert string to JSON
---> 26 self.db.tweets.insert_one(json_data) # store in tweets collection
27 clear_output() # ADDED: show one tweet at a time in Jupyter Notebook
28 print(f' Screen name: {json_data["user"]["name"]}')
~/anaconda3/lib/python3.7/site-packages/pymongo/collection.py in insert_one(self, document, bypass_document_validation, session)
696 write_concern=write_concern,
697 bypass_doc_val=bypass_document_validation,
--> 698 session=session),
699 write_concern.acknowledged)
700
~/anaconda3/lib/python3.7/site-packages/pymongo/collection.py in _insert(self, docs, ordered, check_keys, manipulate, write_concern, op_id, bypass_doc_val, session)
610 return self._insert_one(
611 docs, ordered, check_keys, manipulate, write_concern, op_id,
--> 612 bypass_doc_val, session)
613
614 ids = []
~/anaconda3/lib/python3.7/site-packages/pymongo/collection.py in _insert_one(self, doc, ordered, check_keys, manipulate, write_concern, op_id, bypass_doc_val, session)
598
599 self.__database.client._retryable_write(
--> 600 acknowledged, _insert_command, session)
601
602 if not isinstance(doc, RawBSONDocument):
~/anaconda3/lib/python3.7/site-packages/pymongo/mongo_client.py in _retryable_write(self, retryable, func, session)
1490 """Internal retryable write helper."""
1491 with self._tmp_session(session) as s:
-> 1492 return self._retry_with_session(retryable, func, s, None)
1493
1494 def _reset_server(self, address):
~/anaconda3/lib/python3.7/site-packages/pymongo/mongo_client.py in _retry_with_session(self, retryable, func, session, bulk)
1376 session is not None and
1377 server.description.retryable_writes_supported)
-> 1378 with self._get_socket(server, session) as sock_info:
1379 if retryable and not supports_session:
1380 if is_retrying():
~/anaconda3/lib/python3.7/contextlib.py in __enter__(self)
110 del self.args, self.kwds, self.func
111 try:
--> 112 return next(self.gen)
113 except StopIteration:
114 raise RuntimeError("generator didn't yield") from None
~/anaconda3/lib/python3.7/site-packages/pymongo/mongo_client.py in _get_socket(self, server, session, exhaust)
1221 self, server.description.address, session) as err_handler:
1222 with server.get_socket(
-> 1223 self.__all_credentials, checkout=exhaust) as sock_info:
1224 err_handler.contribute_socket(sock_info)
1225 if (self._encrypter and
~/anaconda3/lib/python3.7/contextlib.py in __enter__(self)
110 del self.args, self.kwds, self.func
111 try:
--> 112 return next(self.gen)
113 except StopIteration:
114 raise RuntimeError("generator didn't yield") from None
~/anaconda3/lib/python3.7/site-packages/pymongo/pool.py in get_socket(self, all_credentials, checkout)
1126 checked_auth = False
1127 try:
-> 1128 sock_info.check_auth(all_credentials)
1129 checked_auth = True
1130 if self.enabled_for_cmap:
~/anaconda3/lib/python3.7/site-packages/pymongo/pool.py in check_auth(self, all_credentials)
710
711 for credentials in cached - authset:
--> 712 auth.authenticate(credentials, self)
713 self.authset.add(credentials)
714
~/anaconda3/lib/python3.7/site-packages/pymongo/auth.py in authenticate(credentials, sock_info)
562 mechanism = credentials.mechanism
563 auth_func = _AUTH_MAP.get(mechanism)
--> 564 auth_func(credentials, sock_info)
565
566
~/anaconda3/lib/python3.7/site-packages/pymongo/auth.py in _authenticate_default(credentials, sock_info)
537 return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-256')
538 else:
--> 539 return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
540 elif sock_info.max_wire_version >= 3:
541 return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
~/anaconda3/lib/python3.7/site-packages/pymongo/auth.py in _authenticate_scram(credentials, sock_info, mechanism)
299 ('conversationId', res['conversationId']),
300 ('payload', Binary(client_final))])
--> 301 res = sock_info.command(source, cmd)
302
303 parsed = _parse_scram_response(res['payload'])
~/anaconda3/lib/python3.7/site-packages/pymongo/pool.py in command(self, dbname, spec, slave_ok, read_preference, codec_options, check, allowable_errors, check_keys, read_concern, write_concern, parse_write_concern_error, collation, session, client, retryable_write, publish_events, user_fields)
611 use_op_msg=self.op_msg_enabled,
612 unacknowledged=unacknowledged,
--> 613 user_fields=user_fields)
614 except OperationFailure:
615 raise
~/anaconda3/lib/python3.7/site-packages/pymongo/network.py in command(sock, dbname, spec, slave_ok, is_mongos, read_preference, codec_options, session, client, check, allowable_errors, address, check_keys, listeners, max_bson_size, read_concern, parse_write_concern_error, collation, compression_ctx, use_op_msg, unacknowledged, user_fields)
165 helpers._check_command_response(
166 response_doc, None, allowable_errors,
--> 167 parse_write_concern_error=parse_write_concern_error)
168 except Exception as exc:
169 if publish:
~/anaconda3/lib/python3.7/site-packages/pymongo/helpers.py in _check_command_response(response, msg, allowable_errors, parse_write_concern_error)
157
158 msg = msg or "%s"
--> 159 raise OperationFailure(msg % errmsg, code, response)
160
161
OperationFailure: сбой аутентификации при неудачной аутентификации.