BeautifulSoup - Misspelled Class
<p>I am attempting to scrape location data from <a href="https://www.wellstar.org/locations/pages/default.aspx" rel="nofollow">https://www.wellstar.org/locations/pages/default.aspx</a> and while I was inspecting the source, I noticed that the class for the hospital's address is sometimes spelled with an extra 'd' - 'adddress' vs 'address'.  Is there a way to account for this difference in the following code?  I have attempted to incorporate an <code>if</code> statement to test the length of the <code>address</code> object but I only get the addresses associated with the 'adddress' class.  I feel that I am close yet out of ideas.</p>

<pre><code>import urllib
import urllib.request
from bs4 import BeautifulSoup
import re

def make_soup(url):
    thepage = urllib.request.urlopen(url)
    soupdata = BeautifulSoup(thepage,"html.parser")
    return soupdata

soup = make_soup("https://www.wellstar.org/locations/pages/default.aspx")

for table in soup.findAll("table",class_="s4-wpTopTable"):
    for type in table.findAll("h3"):
        type = type.get_text()
    for name in table.findAll("div",class_="PurpleBackgroundHeading"):
        name = name.get_text()
    address=""
    for address in table.findAll("div",class_="WS_Location_Adddress"):
            address = address.get_text(separator=" ")
    if len(address)==0:
        for address in table.findAll("div",class_="WS_Location_Address"):
            address = address.get_text(separator = " ")
            print(type, name, address)
</code></pre>

<p><code>BeautifulSoup</code> is great at adapting, you can use a regular expression:</p>

<pre><code>for address in table.find_all("div", class_=re.compile(r"WS_Location_Ad{2,}ress")):
</code></pre>

<p>where <code>d{2,}</code> would match <code>d</code> 2 or more times.</p>

<hr>

<p>Or, you can just specify a <em>list</em> of classes:</p>

<pre><code>for address in table.find_all("div", class_=["WS_Location_Address", "WS_Location_Adddress"]):
</code></pre>

python web-scraping beautifulsoup