Last active
August 29, 2015 14:03
-
-
Save merrypuck/84147acdbd33619bd8a7 to your computer and use it in GitHub Desktop.
Angellist-Api Email Script
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
from urllib import urlopen | |
import json | |
import pymongo | |
from pymongo import MongoClient | |
from urllib import urlopen | |
import json | |
from flask import Flask, render_template, session, request, flash, url_for, redirect | |
from flask.ext.mail import Message, Mail | |
import os | |
app = Flask(__name__) | |
client = MongoClient('localhost') | |
investors_collection = client.valley.investors | |
startup_collection = client.valley.startups | |
emailed_collection = client.valley.emailedStartups | |
mail = Mail() | |
app.config["MAIL_SERVER"] = "smtp.gmail.com" | |
app.config["MAIL_PORT"] = 465 | |
app.config["MAIL_USE_SSL"] = True | |
app.config["MAIL_USERNAME"] = '' | |
app.config["MAIL_PASSWORD"] = '' | |
mail.init_app(app) | |
# Locations | |
# 1691 - Washington DC | |
# 1692 - Silicon Vally | |
# 1693 - San Jose | |
# 2028 - Tel Aviv | |
# 1664 - new york | |
locationId = "1692" | |
# jobs in sf - 37 pages | |
jobUrl = "https://api.angel.co/1/tags/" + locationId + "/jobs?page=1" | |
e = urlopen(jobUrl).read() | |
r = json.loads(e) | |
jobPages = r['last_page'] | |
allStartups = [] | |
counter = 0 | |
for i in range(2, jobPages + 1): | |
thisJobUrl = "https://api.angel.co/1/tags/" + locationId + "/jobs?page=" + str(i) | |
e = urlopen(thisJobUrl).read() | |
r = json.loads(e) | |
for x in range(len(r['jobs'])): | |
startupId = r['jobs'][x]['startup']['id'] | |
if startupId not in allStartups: | |
allStartups.append(startupId) | |
if r['jobs'][x]['startup']['quality'] > 5: | |
counter = counter + 1 | |
emailed_collection.insert({'_id' : r['jobs'][x]['startup']['id'], | |
'startup' : r['jobs'][x]['startup'], | |
'emailTemplate' : '1', | |
'email' : 'Hey guys,\n\nMy name is Aaron Landy, I just left my software engineering job at Glide.me in Israel. I\'m going to be in San Francisco for the week of January 26th and would love to meet about a potential job oppurtnity or simply to get to know each other for the future. My resume is attached.\n\nLooking forward,\n\nAaron Landy\nhttp://aaronlandy.com'}) | |
webUrl = r['jobs'][x]['startup']['company_url'] | |
print webUrl | |
if webUrl[0:8] == "https://": | |
webUrl = webUrl[8:] | |
if webUrl[0:4] == "www.": | |
webUrl = webUrl[4:] | |
elif webUrl[0:7] == "http://": | |
webUrl = webUrl[7:] | |
if webUrl[0:4] == "www.": | |
webUrl = webUrl[4:] | |
if webUrl[-1] == "/": | |
webUrl = webUrl[0:-1] | |
recipientEmail = 'jobs@' + webUrl | |
print recipientEmail | |
msg = Message( | |
subject='Hello / Software development @ ' + r['jobs'][x]['startup']['name'], | |
body='Hey guys,\n\nMy name is Aaron Landy, I just left my software engineering job at Glide.me in Israel. I\'m going to be in San Francisco for the week of January 26th and would love to meet for a potential job oppurtnity or simply to get to know each other for the future. My resume is attached.\n\nLooking forward,\n\nAaron Landy\nhttp://aaronlandy.com', | |
# sender | |
sender=('Aaron Landy', 'aaron@thecompassmag.com'), | |
# recipients | |
recipients=[recipientEmail] | |
) | |
with app.open_resource("Resume.pdf") as fp: | |
# to add email attachment. | |
msg.attach("Resume.pdf", "application/pdf", fp.read()) | |
mail.send(msg) | |
print 'success' | |
# r['jobs'][1]['tags'][1]['name'] + " : " + | |
#print r['jobs'][x]['tags'][1]['name'] + " : " + r['jobs'][x]['startup']['name'] + " : " + str(r['jobs'][x]['startup']['quality']) + " : " + r['jobs'][x]['startup']['company_url'] | |
#else: | |
#print r['jobs'][x]['tags'][1]['name'] | |
print counter | |
#startups by id | |
#startupInfo = "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment