title: Can I join urls using os.path.join() in Python or is there a better way?
body: <p>I need to navigate to different urls to download images from each of them.
  The urls are sequential, so I thought best to manually creating them rather than using the Next button in each page.
  I'm trying to generate the different section of the url and then join them together with os.path.join().</p>
  
  <p>This is my working code:</p>
  
  <pre><code>starting_url = 'https://www.mangareader.net/one-piece'
  storing_folder = '/Users/macbook/Documents/Media/Fumetti/One_Piece'
  ch_numb_regex = re.compile(r'\d+')
  for chapter in os.listdir(storing_folder):
      if not chapter.startswith('.'):
          if os.listdir(os.path.join(storing_folder, chapter)) == []:
              continue
          else:
              try:
                  page = 1
                  while True:
                      res = requests.get(os.path.join(starting_url, str(ch_numb_regex.search(chapter).group()) ,str(page)))
                      res.raise_for_status()
                      manga_soup = bs4.BeautifulSoup(res.text, 'lxml')
                      manga_image = manga_soup.select('#imgholder img')
                      manga_url = manga_image[0].get('src')
                      res = requests.get(manga_url)
                      res.raise_for_status()
                      imageFile = open(os.path.join(storing_folder, chapter, page), 'wb')
                      imageFile.write()
                      imageFile.close()
                      page += 1
              except requests.HTTPError:
                  continue
  </code></pre>
  
  <p>However, I get the error:</p>
  
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-20-1ee22580435e&gt; in &lt;module&gt;()
        7 res = requests.get(manga_url)
        8 res.raise_for_status()
  ----&gt; 9 imageFile = open(os.path.join(storing_folder, chapter, page), 'wb')
       10 imageFile.write()
       11 imageFile.close()
  
  /anaconda3/lib/python3.6/posixpath.py in join(a, *p)
       90                 path += sep + b
       91     except (TypeError, AttributeError, BytesWarning):
  ---&gt; 92         genericpath._check_arg_types('join', a, *p)
       93         raise
       94     return path
  
  /anaconda3/lib/python3.6/genericpath.py in _check_arg_types(funcname, *args)
      147         else:
      148             raise TypeError('%s() argument must be str or bytes, not %r' %
  --&gt; 149                             (funcname, s.__class__.__name__)) from None
      150     if hasstr and hasbytes:
      151         raise TypeError("Can't mix strings and bytes in path components") from None
  
  TypeError: join() argument must be str or bytes, not 'int'
  </code></pre>
  
  <p>But they should all be strings.</p>