title: Execute loop based on a list - obtain result for each page (subpage)
body: <p>I am trying to obtain the number of pages for each url from a list of urls. My code works as long as I have only one url, however as soon as I try it with a list of urls I only get the rest from one url. Guess the problem is related to my loop. given that I am new to python and beautifoul soup I dont manage to spot the mistake myself.</p>
  
  <pre><code>base_url = 'https://www.holidaycheck.de'
  main_page = 'https://www.holidaycheck.de/dh/hotels-tunesien/e10cef63-45d4-3511-92f1-43df5cbd9fe1?p={}'
  urls=[]
  
  ##Change URL into object (soup)
  r = requests.get(main_page.format(0))  
  soup = BeautifulSoup(r.text, "html5lib")
  
  #get max page number
  soup = BeautifulSoup(r.text, 'lxml')
  data = soup.find_all('a', {'class':'link'})
  
  res = []
  for i in data:
      res.append(i.text) #writing each value to res list
  
  res_int = []
  for i in res:
      try:
          res_int.append(int(i))
      except:
          print("current value is not a number")
  last_page=max(res_int)
  #print(last_page)
  
  
  for i in range (1,last_page):
      page = main_page.format(i)
      for link in soup.find_all('div', {'class':'hotel-reviews-bar'}):
         urls = base_url + link.find('a').get('href')+"/-/p/{}"
         print(urls)
  </code></pre>
  
  <p>So far, everything works, I obtain the max page number and get all the urls from each page. The problem lies in the code below (I believe):</p>
  
  <pre><code>for url in urls: #to loop through the list of urls
      r = requests.get(url.format(0)) 
      soup = BeautifulSoup(r.text, 'lxml')
      daten = soup.find_all('a', {'class':'link'})
  
      tes = []
      for z in daten:
          tes.append(z.text) #writing each value to res list
         print(tes)
  
      tes_int = []
      for z in tes:
          try:
              tes_int.append(int(z))
          except:
              print("current value is not a number")
      anzahl=max(tes_int)
      print(anzahl)
  </code></pre>
  
  <p>I am trying to apply the same concept as in the code above for each url from the list urls- but instead of obtaining the max page number for each url I obtain 241 every time, as if I am caught in a loop...</p>
  
  <p>Any thoughts on that? Help is highly appreciated.</p>