title: scraping data from unknown number of pages using beautiful soup
body: <p>I want to parse some info from website that has data spread among several pages.</p>
  
  <p>The problem is I don't know how many pages there are.  There might be 2, but there might be also 4, or even just one page. </p>
  
  <p>How can I loop over pages when I don't know how many pages there will be?</p>
  
  <p>I know however the url pattern which looks something like in the code below.</p>
  
  <p>Also, the pages names are not plain numbers but they are in <code>'pe2'</code> for page 2 and <code>'pe4'</code> for page 3 etc. so can't just loop over range(number). </p>
  
  <p>This dummy code for the loop I am trying to fix.</p>
  
  <pre><code>pages=['','pe2', 'pe4', 'pe6', 'pe8',]
  
  import requests 
  from bs4 import BeautifulSoup
  for i in pages:
      url = "http://www.website.com/somecode/dummy?page={}".format(i)
      r = requests.get(url)
      soup = BeautifulSoup(r.content)
      #rest of the scraping code
  </code></pre>