Extracting a specific list item using Beautiful Soup

Viewed 7840

I am working on a web scraper project using Python and Beautiful Soup. Please have look at the HTML code section which I am having trouble with. Since all the <li> items in the <ul> have the same class names for <div> and <span>, how can I extract the phone number i.e value of second <span> in the third <li> item?

I can extract the <ul> tag and its contents using ad_soup.find("ul",{"class":"Menu"}), but I do not know how to proceed after that. Any help would be highly appreciated.

<ul class="Menu">
  <li>
    <div class="item">
      <span class="name">Name:</span>
      <span class="value">....</span>
    </div>
  </li>
  <li>
    <div class="item">
      <span class="name">Location:</span>
      <span class="value">....</span>
    </div>
  </li>
  <li>
    <div class="item">
      <span class="name">Phone:</span>
      <span class="value">....</span>
    </div>
  </li>
</ul>
2 Answers
Related