def get_title ( soup ) : if soup . title : return soup . title . string if soup . h1 : return soup . h1 . string return ''
string extract title titanic python
Given a soup pick out a title
def get_title(soup):
  """Given a soup, pick out a title"""
  if soup.title:
    return soup.title.string
  if soup.h1:
    return soup.h1.string
  return ''