###前提・実現したいこと
Tweepyでツイートを収集してMySQLに登録したいと思っています。
普通に動くのですが、しばらくするとこのエラーが出てきて困っています。
###発生している問題・エラーメッセージ
エラーメッセージ
Traceback (most recent call last):
File "C:/Users/aaa/OneDrive/Python project/streamingapi.py", line 91, in <module>
stream.filter(locations=[139.605839, 35.436093, 139.670899, 35.470702])
File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 445, in filter
self._start(async)
File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 361, in _start
self._run()
File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 294, in _run
raise exception
File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 263, in _run
self._read_loop(resp)
File "C:\Python34\lib\site-packages\tweepy\streaming.py", line 313, in _read_loop
line = buf.read_line().strip()
AttributeError: 'NoneType' object has no attribute 'strip'
###該当のソースコード
Python
1 2class Listener(tweepy.StreamListener): 3 """ Handles tweets received from the stream. """ 4 5 def on_status(self, status): 6 times = status.created_at + timedelta(hours=9) 7 screen_name = "@" + status.author.screen_name 8 place = status.place.name # 場所 9 geo = str(status.coordinates) # 緯度・経度 10 text_data = status.text # ツイート内容 11 12 # データベースに接続 13 connect = mysql.connector.connect(user='***', 14 password='***', 15 host='***', 16 database='***', 17 charset='utf8mb4', 18 buffered=True 19 ) 20 21 cursor = connect.cursor() 22 23 # insert 24 sql = 'insert into streaming_table VALUES (id, %s, %s, %s, %s, %s)' 25 cursor.execute(sql, (times, screen_name, place, geo, text_data)) 26 27 # select 28 cursor.execute('select * from streaming_table') 29 connect.commit() 30 31 # データベースから切断 32 cursor.close() 33 connect.close() 34 35 return True 36 37 def on_error(self, status_code): 38 print('Got an error with status code: ' + str(status_code)) 39 return True 40 41 def on_timeout(self): 42 print('Timeout...') 43 return True 44 45 46listener = Listener() 47stream = tweepy.Stream(auth, listener) 48stream.filter(locations=[139.605839, 35.436093, 139.670899, 35.470702]) 49 50 51
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。