title: How to scrape website-elements that are using same tags and classes?
body: <p><em>Scraping website-elements that are using same keys and classes &amp; challenges with jumping in loop using Python's BeautifulSoup</em></p>
  <p>I have been looking everywhere for a solution, talked with a software engineer and my python-professor regarding this, which couldn’t help. This is my first post so please bear with me:</p>
  <p>I try to scrape a website using BeautifulSoup to call the elements I want to extract. The main challenge is that the website I try to scrape from, are using the same classes and keys in multiple occations with different elements (In this example: tag = <code>span</code> classes = <code>text-nowrap</code>).
  This means my output from the functions defining the elements I want are printing the same (first HTML-line, which has a tag=<code>span</code> and class = <code>text-nowrap</code> from above).</p>
  <p>In this instance, I thought I might need an additional parameter in the list.find helping it distinguish as some elements consists of special elements like date-format, m², DKK/m² and so forth? Or is there any other ways?</p>
  <p>Furthermore, I seem to have a problem regarding jumping when creating the loop. Printing the soup.find_all class-parameter (in this case, “Container mb-5”), I get all the information I want (unfiltered).However, as soon as I try to create a loop defining the functions of the elements I want printed, the loop only loops once (from the top) giving me one example instead of multiple lines of data. Syntax seems correct.</p>
  <p>Below is my Python-code:</p>
  <pre><code>pip install beautifulsoup4
  pip install lxml
  pip install requests
  
  from bs4
  import BeautifulSoup
  from lxml
  import etree
  import requests
  
  from csv
  import writer
  
  url = &quot;https://www.boliga.dk/salg/resultater?searchTab=1&amp;sort=date-d&amp;saleType=1&amp;propertyType=1,3&amp;salesDateMin=2015&quot;
  page = requests.get(url)
  print(page)
  
  soup = BeautifulSoup(page.content, &quot;html.parser&quot;)
  lists = soup.find_all(&quot;div&quot;, class_ = &quot;container mb-5&quot;)
  
  
  for list in lists:
    resitype = list.find('span', class_ = &quot;text&quot;).text
    address = list.find('a', class_ = &quot;text-primary font-weight-bolder text-left&quot;).text
    price = list.find('span', class_ = &quot;text-nowrap&quot;).text.replace('\xa0kr.', &quot;&quot;)
    salesdate = list.find('span', class_ = &quot;text-nowrap&quot;)
    rooms = list.find('td', class_ = &quot;table-col d-print-table-cell text-center&quot;)
    sqm = list.find('span', class_ = &quot;text-nowrap&quot;)
    sqmprice = list.find('span', class_ = &quot;text-nowrap mt-1&quot;).text
    salestype = list.find('span', class_ = &quot;text-nowrap mt-1&quot;).text
    buildingyear = list.find('span __ngcontent-boliga-app-c182', class_ = &quot;table-col d-print-table-cell text-center&quot;)
    procent = list.find('a', class_ = &quot;price-reduced ng-star-inserted&quot;)
  
  info = [resitype, address, price, salesdate, rooms, sqm, sqmprice, salestype, buildingyear, procent]
  
  print(info)
  </code></pre>