title: How to find and print the page titles of HTML links from one URL in Python 3.5?
body: <p>I'm working on an assignment in which I'm supposed to make a web crawler that reads an input URL, visits each link on the page, and prints the titles of the pages. I don't have a lot of experience with Python, but I had some help, read through a lot of other programs people have written, and currently have this: </p>
  
  <pre><code>from html.parser import HTMLParser
  import urllib.request
  
  class parseText(HTMLParser):
  def handle_starttag(self, tag, attrs):
      print("Start tag:", tag)
      for attr in attrs:
          print("     attr:", attr)
          if tag == "href" in attrs: 
              print(tag)
  
  pageParse = parseText()
  
  req = urllib.request.Request('http://schoolcraft.edu')
  
  pageRequest = urllib.request.urlopen(req)
  pageRequestString = pageRequest.read().decode()
  pageParse.feed(pageRequestString)
  pageParse.close()
  for item in urlText:
      print (item)
  </code></pre>
  
  <p>So I know that it's printing all of the website attributes, instead of just the title, but I'm not sure how to print just the title. Can I still use the HTMLParser module?</p>
  
  <p>Any help is welcome.</p>
  
  <p>EDIT:</p>
  
  <p>I tried the BeautifulSoup code @Padraic posted in python35.exe and I got the following</p>
  
  <p><a href="http://i.stack.imgur.com/gnkBf.png" rel="nofollow">Screencap1</a></p>
  
  <p><a href="http://i.stack.imgur.com/lcgiZ.png" rel="nofollow">Screencap2</a></p>
  
  <p>I changed <code>soup = BeautifulSoup( urllib.request.urlopen(base).read())</code> to <code>soup = BeautifulSoup( urllib.request.urlopen(base).read(), "html.parser")</code> and <code>soup = BeautifulSoup(urllib.request.urlopen(url).read())</code> to  <code>soup = BeautifulSoup(urllib.request.urlopen(url).read(), "html.parser")</code>. This caused me to get the same thing, but without the first error telling me to add <code>"html.parser"</code>.</p>