In [1]:
import tweepy
In [2]:
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
In [3]:
autorizar = tweepy.OAuthHandler(consumer_key, consumer_secret)
autorizar.set_access_token(access_token, access_token_secret)
In [5]:
class DadosPublicosTwitter(tweepy.StreamListener):
def on_status(self, dados):
print("---> ", dados.text)
In [6]:
dados_twitter = DadosPublicosTwitter()
In [7]:
fluxo = tweepy.Stream(autorizar, dados_twitter)
In [8]:
fluxo.filter(track=['Big Data', 'FIA', 'Python'])
---> RT @zdnetfr: Le Big Data, point de passage incontournable de la transformation digitale
https://t.co/63QuZ2BxT3
---> RT @DavidPapp: [TECHCRUNCH] Big data integrator Talend pops 54% in Nasdaq debut, raising $94.5M https://t.co/4kZ0uTwpgl
---> FIA to red-flag qualifying to avoid speeding controversies https://t.co/01B1bblFNz https://t.co/FZR0TUYDzW
---> Autosport: German GP Friday FIA F1 press conference full transcript #F1: https://t.co/Y67wQuCGtm!
---> RT @Hyken: Envisioning the 10–Year Impact of Big Data and Analytics on Commerce #NewWaytoEngage https://t.co/Udupnpomds https://t.co/enW8x7…
---> Big data integrator Talend pops 54% in Nasdaq debut, raising $94.5M https://t.co/mKjxjpEeGh
---> Big data integrator Talend pops 54% in Nasdaq debut, raising $94.5M https://t.co/k30EA5EzZV #OPSItalia
---> Alonso out of patience with FIA after latest rule tweaks https://t.co/hXQAqfZojY via @motorsport
---> Forbes Welcome https://t.co/ZRLGQz3xjU #www #webdesign #webdev #google
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-8-e141c1b23f56> in <module>()
----> 1 fluxo.filter(track=['Big Data', 'FIA', 'Python'])
c:\users\dino\appdata\local\programs\python\python35-32\lib\site-packages\tweepy\streaming.py in filter(self, follow, track, async, locations, stall_warnings, languages, encoding, filter_level)
443 self.session.params = {'delimited': 'length'}
444 self.host = 'stream.twitter.com'
--> 445 self._start(async)
446
447 def sitestream(self, follow, stall_warnings=False,
c:\users\dino\appdata\local\programs\python\python35-32\lib\site-packages\tweepy\streaming.py in _start(self, async)
359 self._thread.start()
360 else:
--> 361 self._run()
362
363 def on_closed(self, resp):
c:\users\dino\appdata\local\programs\python\python35-32\lib\site-packages\tweepy\streaming.py in _run(self)
261 self.snooze_time = self.snooze_time_step
262 self.listener.on_connect()
--> 263 self._read_loop(resp)
264 except (Timeout, ssl.SSLError) as exc:
265 # This is still necessary, as a SSLError can actually be
c:\users\dino\appdata\local\programs\python\python35-32\lib\site-packages\tweepy\streaming.py in _read_loop(self, resp)
311 length = 0
312 while not resp.raw.closed:
--> 313 line = buf.read_line().strip()
314 if not line:
315 self.listener.keep_alive() # keep-alive new lines are expected
c:\users\dino\appdata\local\programs\python\python35-32\lib\site-packages\tweepy\streaming.py in read_line(self, sep)
177 else:
178 start = len(self._buffer)
--> 179 self._buffer += self._stream.read(self._chunk_size)
180
181 def _pop(self, length):
c:\users\dino\appdata\local\programs\python\python35-32\lib\site-packages\requests\packages\urllib3\response.py in read(self, amt, decode_content, cache_content)
299 else:
300 cache_content = False
--> 301 data = self._fp.read(amt)
302 if amt != 0 and not data: # Platform-specific: Buggy versions of Python.
303 # Close the connection when no data is returned
c:\users\dino\appdata\local\programs\python\python35-32\lib\http\client.py in read(self, amt)
431 # Amount is given, implement using readinto
432 b = bytearray(amt)
--> 433 n = self.readinto(b)
434 return memoryview(b)[:n].tobytes()
435 else:
c:\users\dino\appdata\local\programs\python\python35-32\lib\http\client.py in readinto(self, b)
461
462 if self.chunked:
--> 463 return self._readinto_chunked(b)
464
465 if self.length is not None:
c:\users\dino\appdata\local\programs\python\python35-32\lib\http\client.py in _readinto_chunked(self, b)
556 try:
557 while True:
--> 558 chunk_left = self._get_chunk_left()
559 if chunk_left is None:
560 return total_bytes
c:\users\dino\appdata\local\programs\python\python35-32\lib\http\client.py in _get_chunk_left(self)
524 self._safe_read(2) # toss the CRLF at the end of the chunk
525 try:
--> 526 chunk_left = self._read_next_chunk_size()
527 except ValueError:
528 raise IncompleteRead(b'')
c:\users\dino\appdata\local\programs\python\python35-32\lib\http\client.py in _read_next_chunk_size(self)
484 def _read_next_chunk_size(self):
485 # Read the next chunk size from the file
--> 486 line = self.fp.readline(_MAXLINE + 1)
487 if len(line) > _MAXLINE:
488 raise LineTooLong("chunk size")
c:\users\dino\appdata\local\programs\python\python35-32\lib\socket.py in readinto(self, b)
573 while True:
574 try:
--> 575 return self._sock.recv_into(b)
576 except timeout:
577 self._timeout_occurred = True
c:\users\dino\appdata\local\programs\python\python35-32\lib\ssl.py in recv_into(self, buffer, nbytes, flags)
922 "non-zero flags not allowed in calls to recv_into() on %s" %
923 self.__class__)
--> 924 return self.read(nbytes, buffer)
925 else:
926 return socket.recv_into(self, buffer, nbytes, flags)
c:\users\dino\appdata\local\programs\python\python35-32\lib\ssl.py in read(self, len, buffer)
784 raise ValueError("Read on closed or unwrapped SSL socket.")
785 try:
--> 786 return self._sslobj.read(len, buffer)
787 except SSLError as x:
788 if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
c:\users\dino\appdata\local\programs\python\python35-32\lib\ssl.py in read(self, len, buffer)
568 """
569 if buffer is not None:
--> 570 v = self._sslobj.read(len, buffer)
571 else:
572 v = self._sslobj.read(len or 1024)
KeyboardInterrupt:
In [ ]:
Content source: rubensfernando/mba-analytics-big-data
Similar notebooks: