Last active
April 4, 2019 01:10
-
-
Save JohnDeJesus22/538bdddc5febca8b5ad82904f8baef33 to your computer and use it in GitHub Desktop.
Medium web scrap p4
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
# Initiate DataFrame object | |
df = pd.DataFrame() | |
# Get all the teacher names | |
df['Teacher_Names'] = [result.find('h5').text for result in results] | |
# Get all the position titles | |
df['Positions'] = [result.find('p').text.strip('\n\t') for result in results] | |
# Create a function to get emails since some are missing | |
def get_email(teacher_result): | |
try: | |
email = teacher_result.find('em').get_text() | |
except: | |
email = teacher_result.find_all('p')[1].text.strip('\n\t') | |
return email | |
# Get all emails | |
df['Email'] = [get_email(result) for result in results] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment