title: Getting Error "TypeError: expected string or bytes-like object"
body: <p>I am Using Python3 and in my code getting the following error. trying to download pdf and storing in local directory </p>
  
  <pre><code>r_l = 'https://www.ccc.com'
  class Data:
  
      def getlk(self, url):
          all_links = []
          page = requests.get(url)
          soup = BeautifulSoup(page.text, 'html.parser')
          for href in soup.find_all(class_='omrlist'):
              all_links.append(root_url + href.find('a').get('href'))
          return all_links
  
      def getmth_lk(self, ylk):
          rpLk = []
          for url in ylk:
              links = self.getlk(url)
              reportLinks.append(links)
  
  
              for url_ in links:
                  if ".pdf" in url_:
                      if "Annual" not in url_:
                          lastindex = url_.rfind('/')
                          strlen = len(url_)
                          filename = url_[lastindex:strlen].replace("/", "")
  
                          file = pathlib.Path('/home/' + filename)
                          if not file.exists():
                              urllib.request.urlretrieve(rpLk, str(filename))
  
  
  if __name__ == '__main__':
      obj = Data()
      yLk = obj.getlk(r_l + '/oil/reports/')
      mth_lk = obj.getmth_lk(yLk)
  </code></pre>
  
  <p>I tried the above code but the error is comming</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/dwnpdf-to-dir.py", line 248, in &lt;module&gt;
      mth_lk = obj.getmth_lk(yLk)
    File "/home/dwnpdf-to-dir.py", line 228, in getmth_lk
      urllib.request.urlretrieve(rpLk, str(filename))
    File "/usr/lib/python3.5/urllib/request.py", line 186, in urlretrieve
      url_type, path = splittype(url)
    File "/usr/lib/python3.5/urllib/parse.py", line 861, in splittype
      match = _typeprog.match(url)
  TypeError: expected string or bytes-like object
  </code></pre>
  
  <p>the above error is coming So, pleas guide me to overcome from this error</p>