title: How can i get only name and contact number?
body: <p>I'm trying to get name and contact number from div. div sometimes has one span, sometimes two, and sometimes three. My expectation is that:</p>
  
  <ul>
  <li>I only need name and contact number if available</li>
  <li>In some cases, name will not be available and contact number will be available, then name variable should be assigned 'N/A'</li>
  <li>In some cases, contact number will not be available and name will be available, then variable should be assigned 'N/A'</li>
  </ul>
  
  <p>This is what I have so far:</p>
  
  <pre><code>// if you change url to url-1 and url-2 then you will see how it works.
  url = "https://www.zillow.com/homedetails/19442-185th-Ave-SE-Renton-WA- 
  98058/54831221_zpid/"
  #url-1 = "https://www.zillow.com/homedetails/20713-61st-St-E-Bonney-Lake-WA-98391/99371104_zpid/"
  #url-2 = "https://www.zillow.com/homes/fsbo/house_type/121319389_zpid/globalrelevanceex_sort/47.465758,-122.259207,47.404798,-122.398424_rect/12_zm/5f9305c92cX1-CRbri51bo8epha_yly1g_crid/0_mmm/"
  browser = webdriver.Firefox()
  browser.get(url)
  time.sleep(5)
  
  soup = bs4.BeautifulSoup(browser.page_source,'html.parser')
  
  contacts = browser.find_elements_by_css_selector("span.listing-field")
  contact_name = []
  contact_phone = "N/A"
  contact_web = "N/A"
  
  for i in range(0, len(contacts)):
      if len(contacts[i].find_elements_by_tag_name("a")) &gt; 0:
      contact_web = 
      contacts[i].find_element_by_tag_name("a").get_attribute("href")
      elif re.search("\\(\\d+\\)\\s+\\d+-\\d+", contacts[i].text):
          contact_phone = contacts[i].text
      else:
          contact_name.append(contacts[i].text)
  
  print(contact_phone) // Output: (253) 335-8690
  print(contact_name)  // Output: ['Sheetal Datta']
  </code></pre>