Skip to content

Instantly share code, notes, and snippets.

@JohnDeJesus22
Last active April 4, 2019 01:10
Show Gist options
  • Save JohnDeJesus22/538bdddc5febca8b5ad82904f8baef33 to your computer and use it in GitHub Desktop.
Save JohnDeJesus22/538bdddc5febca8b5ad82904f8baef33 to your computer and use it in GitHub Desktop.
Medium web scrap p4
# 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