add option to get tweets from one user

This commit is contained in:
j 2013-08-01 15:14:06 +02:00
parent 3bf45b9d33
commit 3cc5659310

View file

@ -8,9 +8,11 @@ import lxml.html
import ox
from ox.cache import read_url
def find(query, timeout=60):
url = 'https://twitter.com/search/' + quote(query)
def find(query=None, user=None, timeout=60):
if user:
url = 'https://twitter.com/' + quote(user)
else:
url = 'https://twitter.com/search/' + quote(query)
data = ox.cache.read_url(url, timeout=timeout).decode('utf-8')
doc = lxml.html.document_fromstring(data)
tweets = []