title: Python 3.6: TypeError: a bytes-like object is required, not 'str' when trying to print all links in a page
body: <p>I'm attending an online course on Python for beginners. The course explained how to print all links in web page source code. I wrote the codes for doing this using Notepad++, and then pasted them into the Python interpreter (Python 3.6 on Windows). </p>
  
  <pre><code>def get_next_target(page):
      start_link=page.find('&lt;a href=')
      if start_link==-1:
          return None,0
      start_quote=page.find('"',start_link)
      end_quote=page.find('"',start_quote+1)
      url=page[start_quote+1,end_quote]
      return url,end_quote
  
  def print_all_links(page):
      while True:
          url,endpos=(get_next_target(page))
          if url:
              print(url)
              page=page[endpos:]
          else:
              break
  
  def get_page(url):
      import urllib.request
      return urllib.request.urlopen(url).read()
  
  print_all_links(get_page('https://youtube.com'))
  </code></pre>
  
  <p>After I hit Enter, I got this:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;stdin&gt;", line 3, in print_all_links
    File "&lt;stdin&gt;", line 2, in get_next_target
  TypeError: a bytes-like object is required, not 'str'
  </code></pre>
  
  <p>I cannot figure out what's wrong with my codes.</p>