python - Trying to capture data from twitter hashtag feeds using tweepy -
when running server following error
valueerror @ / view hashtrack.views.index didn't return httpresponse object. returned none instead. request method: request url: http://127.0.0.1:8000/ django version: 1.8.2 exception type: valueerror exception value: view hashtrack.views.index didn't return httpresponse object. returned none instead. exception location: c:\python34\lib\site-packages\django\core\handlers\base.py in get_response, line 151 python executable: c:\python34\python.exe python version: 3.4.3 python path: ['c:\\users\\torjeli\\tweesh', 'c:\\python34\\lib\\site-packages\\setuptools-15.2-py3.4.egg', 'c:\\python34\\lib\\site-packages\\distribute-0.6.49-py3.4.egg', 'c:\\python34\\lib\\site-packages\\cython-0.22-py3.4-win32.egg', 'c:\\python34\\lib\\site-packages\\scrapy-0.24.6-py3.4.egg', 'c:\\python34\\lib\\site-packages\\six-1.9.0-py3.4.egg', 'c:\\python34\\lib\\site-packages\\cssselect-0.9.1-py3.4.egg', 'c:\\python34\\lib\\site-packages\\pyopenssl-0.15.1-py3.4.egg', 'c:\\windows\\system32\\python34.zip', 'c:\\python34\\dlls', 'c:\\python34\\lib', 'c:\\python34', 'c:\\python34\\lib\\site-packages', 'c:\\python34\\lib\\site-packages\\win32', 'c:\\python34\\lib\\site-packages\\win32\\lib', 'c:\\python34\\lib\\site-packages\\pythonwin'] server time: sun, 31 may 2015 18:59:22 -0400
i have tried running script on background of page same error code, hashtags printed in console window, i'm trying tweets csv file later use data.
from django.shortcuts import render_to_response django.http import httpresponse tweepy import * ckey = 'xxxxx' #api key consec = 'xxxxx' #consumer secret acctok = 'xxxxx' #access token acctsec = 'xxxxx' #access token secret class stdoutlistener(streamlistener): def on_status(self, status): print(status.text) return true def on_error(self, status): print(status) def index(request): try: listener = stdoutlistener() auth = oauthhandler(ckey, consec) auth.set_access_token(acctok, acctsec) stream = stream(auth, listener) gimme = stream.filter(track=["lol"]) return httpresponse(gimme) #return render_to_response('index.html') except runtimeerror: pass
so, managed capture data on csv, page doesnt load while process running.... csv file information wanted.
from django.http import httpresponse tweepy import * ckey = 'xxxxx' #api key consec = 'xxxxx' #consumer secret acctok = 'xxxxx' #access token acctsec = 'xxxxx' #access token secret class stdoutlistener(streamlistener): def on_status(self, status): try: hashdb = open("hashtag.csv", 'a') hashdb.write(status.text) hashdb.write('\n') hashdb.close() except baseexception: print("could not process") def on_error(self, status_code): print(status_code) return status_code def index(request): listener = stdoutlistener() auth = oauthhandler(ckey, consec) auth.set_access_token(acctok, acctsec) stream = stream(auth, listener) gimme = stream.filter(track=["lol"]) html = "<html><body>it %s.</body></html>" % gimme return httpresponse(html)
Comments
Post a Comment