Created
November 14, 2010 12:56
-
-
Save gerald-kim/676141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from mechanize import Browser | |
br = Browser() | |
br.set_handle_robots(False) | |
br.open("http://www.instapaper.com") | |
br.follow_link(text="Log In") | |
#print br.title() | |
br.select_form(nr=0) | |
br['username'] = #YOUR_INSTAPAPER_ACCOUNT# | |
br['password'] = #YOUR_INSTAPAPER_PASSWORD# | |
br.submit() | |
response = br.follow_link(url='/mobi') | |
info = response.info() | |
filename = #DOWNLOAD_LOCATION# | |
f = open(filename, 'w') | |
f.write( response.read() ) | |
f.close() | |
import smtplib | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email.MIMEText import MIMEText | |
from email import Encoders | |
import os | |
gmail_user = #YOUR_GMAIL_ADDRESS# | |
gmail_pwd = #YOUR_GMAIL_PASSWORD# | |
def send_gmail(to, subject, text, attach): | |
msg = MIMEMultipart() | |
msg['From'] = gmail_user | |
msg['To'] = to | |
msg['Subject'] = subject | |
msg.attach(MIMEText(text)) | |
part = MIMEBase('application', 'octet-stream') | |
part.set_payload(open(attach, 'rb').read()) | |
Encoders.encode_base64(part) | |
part.add_header('Content-Disposition', 'attachment; filename="%s";' % os.path.basename(attach)) | |
msg.attach(part) | |
mailServer = smtplib.SMTP("smtp.gmail.com", 587) | |
mailServer.ehlo() | |
mailServer.starttls() | |
mailServer.ehlo() | |
mailServer.login(gmail_user, gmail_pwd) | |
mailServer.sendmail(gmail_user, to, msg.as_string()) | |
mailServer.close() | |
send_gmail(#YOUR_KINDLE_EMAIL_ADDRESS#, 'instapaper', 'body', filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment