30 lines
783 B
Python
Executable file
30 lines
783 B
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import dbtools, tools
|
|
|
|
def fill(db=dbtools.dbObject(), user=tools.user(), two=tools.twObject()):
|
|
query = "from:" + user
|
|
savepoint = db.getLatestTweet()
|
|
last = savepoint
|
|
|
|
timeline = two.search(query, savepoint)
|
|
|
|
tw_counter = 0
|
|
|
|
for status in timeline:
|
|
timestamp = status.created_at.strftime('%Y-%m-%d %H:%M:%S') + " +0000"
|
|
text = tools.unescapeText(status.text)
|
|
|
|
db.executeQuery("INSERT INTO tweets('tweet_id','timestamp','text') VALUES(" + str(status.id) + ",'" + timestamp + "','" + text + "')")
|
|
db.commit()
|
|
|
|
last = status.id
|
|
tw_counter = tw_counter + 1
|
|
|
|
db.closeConnection()
|
|
|
|
return tw_counter, last, savepoint
|
|
|
|
if __name__ == "__main__":
|
|
count, last, first = fill()
|
|
print("Stored %i tweets after %i until %i." % (count, first, last))
|