Ejemplo n.º 1
0
class FullContact_Client:

    def __init__(self):

        self.fc = FullContact('ab76dbb1c4b8c50f')


    def searchbyemail(self, email):

        return self.fc.get(email=email)
Ejemplo n.º 2
0
def get_identity(config, email):
  fc = FullContact(config['FC_KEY'])

  db = divan.Database(config['DB_URI'],
                        config['DB_NAME'],
                        auth=(config['DB_USER'],
                              config['DB_PASS']))
  try:
    res = db.get_or_create()
    assert res.status_code in [200, 201]
  except AssertionError:
    return res.status_code, res.json()
  else:
    res = db.get(email)
    if res.status_code == 200:
      return res.status_code, res.json()
    else:
      profile = fc.get(email=email)
      if profile['status'] == 200:
        profile['_id'] = email
        res = db.post(params=profile)
        return res.status_code, profile
      else:
        return profile['status'], profile
Ejemplo n.º 3
0
def hello():
    first_name = request.form['firstName']
    last_name = request.form['lastName']
    company_url = request.form['companyUrl']
    source = "Ad Hoc"
    api_key = "ddb2740f8d2338c78497519c13cc7076"
    params = {
        'key': api_key,
        'domain': company_url,
        'first': first_name,
        'last': last_name
    }

    toofr_url = "http://toofr.com/api/guess?"
    test = requests.get(toofr_url, params=params)
    toofr_data = test.json()

    try:
        toofr_email = toofr_data['response']['email']
    except:
        toofr_email = None
    try:
        toofr_confidence = toofr_data['response']['confidence']
    except:
        toofr_confidence = None
    toofr_data = pd.DataFrame(columns=('toofr_email', 'first_name',
                                       'last_name', 'toofr_confidence',
                                       'company_url', 'source'))

    existing_records_final_links = len(toofr_data)
    toofr_data.loc[existing_records_final_links] = [
        toofr_email, first_name, last_name, toofr_confidence, company_url,
        source
    ]
    toofr_data.to_sql("investor_toofr_data",
                      con=conn,
                      flavor='mysql',
                      if_exists='append',
                      index=False)

    query = '''
    select td.id,td.toofr_email as email
    from investor_toofr_data td
    having td.id =  (select max(id)
                     from investor_toofr_data);'''

    toofr_data = psql.read_frame(query, conn)
    toofr_data_dict = {}
    toofr_data_dict = toofr_data.set_index('id').to_dict()
    toofr_data_dict = toofr_data_dict['email']

    for key, value in toofr_data_dict.items():
        fc = FullContact('76152464a239f71c')
        print key, value
        person_profile = fc.get(email=value)

        if person_profile['status'] == 200:
            rep_gender = None
            rep_location = None
            rep_klout_score = None
            rep_klout_topic = None
            rep_facebook_url = None
            rep_facebook_followers = None
            rep_facebook_following = None
            rep_linkedin_url = None
            rep_twitter_url = None
            rep_twitter_followers = None
            rep_twitter_following = None
            rep_angellist_url = None
            rep_angellist_followers = None

            try:
                rep_gender = person_profile['demographics']['gender']
            except:
                print 'gender_missing'
            try:
                rep_location = person_profile['demographics'][
                    'locationGeneral']
            except:
                print 'location_missing'

            try:
                rep_klout_score = person_profile['digitalFootprint']['scores'][
                    0]['value']
            except:
                print 'klout score missing'
            try:
                rep_klout_topic = person_profile['digitalFootprint']['topics'][
                    0]['value']
            except:
                print 'klout topic missing'

            try:
                rep_social_profiles = person_profile['socialProfiles']
                if len(rep_social_profiles) > 0:
                    for i in xrange(0, len(rep_social_profiles)):
                        if rep_social_profiles[i]['typeName'] == 'Facebook':
                            try:
                                rep_facebook_url = rep_social_profiles[i][
                                    'url']
                            except:
                                print 'facebook url missing'
                            try:

                                rep_facebook_followers = rep_social_profiles[
                                    i]['followers']
                            except:
                                print 'facebook followers missing'
                            try:
                                rep_facebook_following = rep_social_profiles[
                                    i]['following']
                            except:
                                print 'facebook following missing'
                        if rep_social_profiles[i]['typeName'] == 'LinkedIn':
                            try:
                                rep_linkedin_url = rep_social_profiles[i][
                                    'url']
                            except:
                                print 'linkedin url missing'
                        if rep_social_profiles[i]['typeName'] == 'Twitter':
                            try:
                                rep_twitter_url = rep_social_profiles[i]['url']
                            except:
                                print 'twitter url missing'
                            try:

                                rep_twitter_followers = rep_social_profiles[i][
                                    'followers']
                            except:
                                print 'twitter followers missing'
                            try:

                                rep_twitter_following = rep_social_profiles[i][
                                    'following']
                            except:
                                print 'twitter following missing'
                        if rep_social_profiles[i]['typeName'] == 'AngelList':
                            try:

                                rep_angellist_url = rep_social_profiles[i][
                                    'url']
                            except:
                                print 'angel list url missing'
                            try:

                                rep_angellist_followers = rep_social_profiles[
                                    i]['followers']
                            except:
                                print 'angel list followers missing'
            except:
                print 'no social profile found'

            data = pd.DataFrame(
                columns=('toofr_id', 'rep_gender', 'rep_location',
                         'rep_klout_score', 'rep_klout_topic',
                         'rep_facebook_url', 'rep_facebook_followers',
                         'rep_facebook_following', 'rep_linkedin_url',
                         'rep_twitter_url', 'rep_twitter_followers',
                         'rep_twitter_following', 'rep_angellist_url',
                         'rep_angellist_followers'))

            existing_records_final_links = len(data)
            data.loc[existing_records_final_links] = [
                key, rep_gender, rep_location, rep_klout_score,
                rep_klout_topic, rep_facebook_url, rep_facebook_followers,
                rep_facebook_following, rep_linkedin_url, rep_twitter_url,
                rep_twitter_followers, rep_twitter_following,
                rep_angellist_url, rep_angellist_followers
            ]
            data = data.where(pd.notnull(data), None)
            data.to_sql('fullcontact',
                        con=conn,
                        flavor='mysql',
                        if_exists='append',
                        index=False)
    return render_template('form_action.html',
                           firstName=first_name,
                           lastName=last_name)
Ejemplo n.º 4
0
def hello():
    first_name = request.form["firstName"]
    last_name = request.form["lastName"]
    company_url = request.form["companyUrl"]
    source = "Ad Hoc"
    api_key = "ddb2740f8d2338c78497519c13cc7076"
    params = {"key": api_key, "domain": company_url, "first": first_name, "last": last_name}

    toofr_url = "http://toofr.com/api/guess?"
    test = requests.get(toofr_url, params=params)
    toofr_data = test.json()

    try:
        toofr_email = toofr_data["response"]["email"]
    except:
        toofr_email = None
    try:
        toofr_confidence = toofr_data["response"]["confidence"]
    except:
        toofr_confidence = None
    toofr_data = pd.DataFrame(
        columns=("toofr_email", "first_name", "last_name", "toofr_confidence", "company_url", "source")
    )

    existing_records_final_links = len(toofr_data)
    toofr_data.loc[existing_records_final_links] = [
        toofr_email,
        first_name,
        last_name,
        toofr_confidence,
        company_url,
        source,
    ]
    toofr_data.to_sql("investor_toofr_data", con=conn, flavor="mysql", if_exists="append", index=False)

    query = """
    select td.id,td.toofr_email as email
    from investor_toofr_data td
    having td.id =  (select max(id)
                     from investor_toofr_data);"""

    toofr_data = psql.read_frame(query, conn)
    toofr_data_dict = {}
    toofr_data_dict = toofr_data.set_index("id").to_dict()
    toofr_data_dict = toofr_data_dict["email"]

    for key, value in toofr_data_dict.items():
        fc = FullContact("76152464a239f71c")
        print key, value
        person_profile = fc.get(email=value)

        if person_profile["status"] == 200:
            rep_gender = None
            rep_location = None
            rep_klout_score = None
            rep_klout_topic = None
            rep_facebook_url = None
            rep_facebook_followers = None
            rep_facebook_following = None
            rep_linkedin_url = None
            rep_twitter_url = None
            rep_twitter_followers = None
            rep_twitter_following = None
            rep_angellist_url = None
            rep_angellist_followers = None

            try:
                rep_gender = person_profile["demographics"]["gender"]
            except:
                print "gender_missing"
            try:
                rep_location = person_profile["demographics"]["locationGeneral"]
            except:
                print "location_missing"

            try:
                rep_klout_score = person_profile["digitalFootprint"]["scores"][0]["value"]
            except:
                print "klout score missing"
            try:
                rep_klout_topic = person_profile["digitalFootprint"]["topics"][0]["value"]
            except:
                print "klout topic missing"

            try:
                rep_social_profiles = person_profile["socialProfiles"]
                if len(rep_social_profiles) > 0:
                    for i in xrange(0, len(rep_social_profiles)):
                        if rep_social_profiles[i]["typeName"] == "Facebook":
                            try:
                                rep_facebook_url = rep_social_profiles[i]["url"]
                            except:
                                print "facebook url missing"
                            try:

                                rep_facebook_followers = rep_social_profiles[i]["followers"]
                            except:
                                print "facebook followers missing"
                            try:
                                rep_facebook_following = rep_social_profiles[i]["following"]
                            except:
                                print "facebook following missing"
                        if rep_social_profiles[i]["typeName"] == "LinkedIn":
                            try:
                                rep_linkedin_url = rep_social_profiles[i]["url"]
                            except:
                                print "linkedin url missing"
                        if rep_social_profiles[i]["typeName"] == "Twitter":
                            try:
                                rep_twitter_url = rep_social_profiles[i]["url"]
                            except:
                                print "twitter url missing"
                            try:

                                rep_twitter_followers = rep_social_profiles[i]["followers"]
                            except:
                                print "twitter followers missing"
                            try:

                                rep_twitter_following = rep_social_profiles[i]["following"]
                            except:
                                print "twitter following missing"
                        if rep_social_profiles[i]["typeName"] == "AngelList":
                            try:

                                rep_angellist_url = rep_social_profiles[i]["url"]
                            except:
                                print "angel list url missing"
                            try:

                                rep_angellist_followers = rep_social_profiles[i]["followers"]
                            except:
                                print "angel list followers missing"
            except:
                print "no social profile found"

            data = pd.DataFrame(
                columns=(
                    "toofr_id",
                    "rep_gender",
                    "rep_location",
                    "rep_klout_score",
                    "rep_klout_topic",
                    "rep_facebook_url",
                    "rep_facebook_followers",
                    "rep_facebook_following",
                    "rep_linkedin_url",
                    "rep_twitter_url",
                    "rep_twitter_followers",
                    "rep_twitter_following",
                    "rep_angellist_url",
                    "rep_angellist_followers",
                )
            )

            existing_records_final_links = len(data)
            data.loc[existing_records_final_links] = [
                key,
                rep_gender,
                rep_location,
                rep_klout_score,
                rep_klout_topic,
                rep_facebook_url,
                rep_facebook_followers,
                rep_facebook_following,
                rep_linkedin_url,
                rep_twitter_url,
                rep_twitter_followers,
                rep_twitter_following,
                rep_angellist_url,
                rep_angellist_followers,
            ]
            data = data.where(pd.notnull(data), None)
            data.to_sql("fullcontact", con=conn, flavor="mysql", if_exists="append", index=False)
    return render_template("form_action.html", firstName=first_name, lastName=last_name)