├── README.md ├── SocialProfiles-LogicLady.py └── _config.yml /README.md: -------------------------------------------------------------------------------- 1 | # **email-saga** 2 | ### Extract Social Media Profiles and Associated Data:
Tell a Story Using Just an Email Address!     3 | + Written in **python 3** using packages `pandas` and `python-intercom` 4 | + Input: `csv` for processing many email addresses at onc 5 | + Output: `csv` for easy review of collected social media data 6 | -------------------------------------------------------------------------------- /SocialProfiles-LogicLady.py: -------------------------------------------------------------------------------- 1 | # pandas and python-intercom packages need to be installed via pip 2 | import pandas 3 | from intercom.client import Client 4 | ### USER INPUT 5 | INTERCOM_ACCESS_TOKEN = 'dG9rOjQ2MmM2MzlkXzQwNzRfNGVkYl84YjYwXzkwZDVmNzcyMzcyMjoxOjA=' 6 | INPUT_FILE = 'emails.csv' 7 | OUTPUT_FILE = 'SocialProfiles-out.csv' 8 | EMAILS_HEADER = 'Emails' 9 | 10 | # intercom API extended access token 11 | intercom = Client(personal_access_token=INTERCOM_ACCESS_TOKEN) 12 | # create dataframe from input CSV which should be in the same directory and have column A listing email addresses with header 'Emails' 13 | df = pandas.DataFrame(pandas.read_csv(INPUT_FILE)) 14 | 15 | sites = [ 16 | ['Twitter', 'Twitter Username', [], 'Twitter URL', []], 17 | ['Facebook', 'Facebook Username', [], 'Facebook URL', []], 18 | ['LinkedIn', 'LinkedIn Username', [], 'LinkedIn URL', []], 19 | ['Klout', 'Klout Username', [], 'Klout URL', []], 20 | ['Vimeo', 'Vimeo Username', [], 'Vimeo URL', []], 21 | ['GooglePlus', 'Google Plus Username', [], 'Google Plus URL', []], 22 | ['Flickr', 'Flickr Username', [], 'Flickr URL', []], 23 | ['Github', 'GitHub Username', [], 'GitHub URL', []], 24 | ['Foursquare', 'FourSquare Username', [], 'FourSquare URL', []], 25 | ['YouTube', 'YouTube Username', [], 'YouTube URL', []], 26 | ['Myspace', 'MySpace Username', [], 'MySpace URL', []], 27 | ['Tumblr', 'Tumblr Username', [], 'Tumblr URL', []] 28 | ] 29 | others = ['Other Username', [], 'Other URL', [], 'Other Type', []] 30 | avatars = ['Avatar URL', []] 31 | titles = ['Job Title', []] 32 | 33 | site_list = [] 34 | emailnum = 0 35 | 36 | for site in sites: 37 | site_list.append(site[0]) 38 | 39 | for email in df[EMAILS_HEADER]: 40 | emailnum += 1 41 | intercom.users.create(email=email) 42 | user = intercom.users.find(email=email) 43 | avatars[1].append(user.avatar.image_url) 44 | if len(user.custom_attributes) > 0: 45 | if str(user.custom_attributes)[2:11] == 'job_title': 46 | titles[1].append(str(user.custom_attributes)[15:len(str(user.custom_attributes))-2]) 47 | else: 48 | print("Unknown Custom Attribute: " + user.custom_attributes) 49 | for profile in user.social_profiles: 50 | for site in sites: 51 | if profile.name == site[0]: 52 | site[2].append(profile.username) 53 | site[4].append(profile.url) 54 | if profile.name not in site_list: 55 | others[1].append(profile.username) 56 | others[3].append(profile.url) 57 | others[5].append(profile.name) 58 | for l in (others[1], others[3], others[5], titles[1]): 59 | if len(l) < emailnum: 60 | l.append("") 61 | for site in sites: 62 | if len(site[2]) < emailnum: 63 | site[2].append("") 64 | if len(site[4]) < emailnum: 65 | site[4].append("") 66 | 67 | # add arrays to dataframe 68 | for site in sites: 69 | df[site[1]] = pandas.Series(site[2]) 70 | df[site[3]] = pandas.Series(site[4]) 71 | df[others[0]] = pandas.Series(others[1]) 72 | df[others[2]] = pandas.Series(others[3]) 73 | df[others[4]] = pandas.Series(others[5]) 74 | df[avatars[0]] = pandas.Series(avatars[1]) 75 | df[titles[0]] = pandas.Series(titles[1]) 76 | # Write dataframe to output CSV 77 | df.to_csv(OUTPUT_FILE,index=False) 78 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-time-machine --------------------------------------------------------------------------------