Skip to content

Commit 922b393

Browse files
committed
updating without simplejson
1 parent 04bb900 commit 922b393

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*~
22
*.pyc
3+
scrape_my_netflix.py

scraper.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import urllib2
2-
import simplejson
32
from lxml import html
43
from email.MIMEText import MIMEText
54
import smtplib
@@ -13,7 +12,7 @@ def send_email(subject, message, from_addr=GMAIL_LOGIN, to_addr=GMAIL_LOGIN):
1312
msg['From'] = from_addr
1413
msg['To'] = to_addr
1514
msg['Reply-To'] = 'happyhours@noreply.com'
16-
15+
1716
server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or 587
1817
server.ehlo()
1918
server.starttls()
@@ -46,37 +45,37 @@ def get_all_tags(url,tag):
4645
'table table div table td')
4746

4847

49-
# Then, I'm going to sort out the *exact* parts of the page
48+
# Then, I'm going to sort out the *exact* parts of the page
5049
# that match what I'm looking for...
5150
for t in tables:
5251
if t.cssselect('p.calendar_EventTitle'):
5352
found_happy_hours.append(t.text_content())
5453

5554
print "The scraper found %d happy hours!" % len(found_happy_hours)
56-
57-
# Now I'm going to loop through the food I like
55+
56+
# Now I'm going to loop through the food I like
5857
# and see if any of the happy hour descriptions match
5958
for food in stuff_i_like:
6059
for hh in found_happy_hours:
6160
# checking for text AND making sure I don't have duplicates
62-
if food in hh and hh not in my_happy_hours:
61+
if food in hh and hh not in my_happy_hours:
6362
print "YAY! I found some %s!" % food
6463
my_happy_hours.append(hh)
65-
64+
6665
print "I think you might like %d of them, yipeeeee!" % len(my_happy_hours)
67-
66+
6867
#Now, let's make a mail message we can read:
6968
message = 'Hey Katharine,\n\n\n'
70-
message += 'OMG, I found some stuff for you in Downtown, take a look.\n\n'
69+
message += 'OMG, I found some stuff for you in Downtown, take a look.\n\n'
7170
message += '==============================\n'.join(my_happy_hours)
72-
message = message.encode('utf-8')
71+
message = message.encode('utf-8')
7372
# To read more about encoding:
7473
# http://diveintopython.org/xml_processing/unicode.html
7574
message = message.replace('\t','').replace('\r','')
7675
message += '\n\nXOXO,\n Your Py Script'
7776

7877
#And email it to ourselves!
7978
email = 'katharine@pyladies.com'
80-
send_email('Happy Hour Update',message,
79+
send_email('Happy Hour Update',message,
8180
from_addr=GMAIL_LOGIN, to_addr=email)
8281

0 commit comments

Comments
 (0)