title: Web Scraping with Python - Selecting div, h2 and h3 class
body: <p>This is my first time with Python and web scraping. Have been looking around and still unable to get what I need to do.</p>
  
  <p>Below are print screen of the elements that I've used via Chrome.</p>
  
  <p>What I am trying to do is that, I am trying to get the apartment names and the address from the selected city name.</p>
  
  <p><img src="https://i.stack.imgur.com/LvaKF.png" alt="List of Apartments in a selected city"></p>
  
  <pre><code>import requests
  from bs4 import BeautifulSoup
  
  #url = 'http://www.homestead.ca/apartments-for-rent/'                           
  rootURL = 'http://www.homestead.ca'
  response = requests.get(rootURL)                                                   
  html = response.content
  soup = BeautifulSoup(html,'lxml')
  
  dropdown_list = soup.select(".primary .child-pages a")
  
  #city_names=[dropdown_list_value.text for dropdown_list_value in dropdown_list]
  #print (city_names)
  
  cityLinks=[rootURL + dropdown_list_value['href'] for dropdown_list_value in dropdown_list]
  
  for cityLinks_select in dropdown_list:                                       #Looping each city from the Apartment drop down list
      print ('Selecting city:',cityLinks_select.text)
      cityResponse = requests.get(cityLinks)
      cityHtml = cityResponse.content
      citySoup = BeautifulSoup(cityHtml,'lxml')
  
      community_list = soup.select(".extended-search .property-container a[h2 h3]")
      get and print the apartment link
      get and print the apartment name
      get and print the address of the apartment
  </code></pre>