I recently posted here, but I was not able to solve the problem so I'm asking again. I'm trying to scrape this website for 'Recent Sales' section (all the addresses): https://www.compass.com/agents/irene-vuong/
My code looks like this:
listings = []
for item in soup.findAll('a', {'class':'uc-listingCard-title'}):
listings.append(item.get_text(strip=True))
print(listings)
My output is :
['256-258 Wyckoff Street', '1320 Glenwood Road', '1473 East 55th Street', '145 Winter Avenue', '25-02 Brookhaven Avenue']
However expected out would be:
['256-258 Wyckoff Street', '1320 Glenwood Road', '1473 East 55th Street', '145 Winter Avenue', '25-02 Brookhaven Avenue', '352 94th Street', '1754 West 12th Street', '2283 E 23rd st', '2063 Brown Street, '3423 Avenue U', '2256 Stuart Street']
Which contians all address as the class name is same as
<a class="uc-listingCard-title" href="`````" data-tn="listingCard-label-address"> adress here </a>
I don't understand why my code only gets first part but not the whole addresses when it has same class name.
Thank you in advance for any help.
++++ With suggestions:
for item in soup.findAll('div', attrs={'class': 'uc-listingCard-content'}):
new = item.find('a', attrs={'class': 'uc-listingCard-title'})
print(new.text)
I still only get the current listing addresses but NOT ALL addresses.