-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtweet_parser.py
More file actions
55 lines (50 loc) · 1.59 KB
/
tweet_parser.py
File metadata and controls
55 lines (50 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
"""
Uses Twython to search through tweets by @dumpmon to determine if certain information shows up in information dumps
"""
import sys
import string
import simplejson
import urllib2
import smtplib
import time
import datetime
from info import *
from twython import TwythonStreamer
class MyStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
message = data['text'].encode('utf-8')
split_message = message.split()
response = urllib2.urlopen(split_message[0])
html = response.read()
time = datetime.datetime.now()
timeofday = time.time()
day = int(time.day)
month = int(time.month)
year = int(time.year)
found_info = "file_%i_%i_%i_%s.txt" % (month, day, year,timeofday)
fp = open(found_info, "w")
for substring in substrings:
print substring
if substring in html:
fp.write(html);
fp.close()
msg = "\r\n".join([
"From: %s" % fromaddr,
"To: %s" % toaddrs,
"Subject: Just a message",
"",
"This email: " + substring + " was found on " + time.strftime("%c") + " at " + split_message[0]
])
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
print message
def on_error(self, status_code, data):
print status_code
stream = MyStreamer(app_key=key, app_secret=secret_key, oauth_token=token, oauth_token_secret=token_secret)
stream.statuses.filter(follow="1231625892")