I'm having a devil of a time trying to get the text from a list of items on petango.com. Screenshot of html below I load the page using selenium to let it load. then grab it for a bs object
PetSoup = BeautifulSoup(page_source, 'html.parser')
I've tried:
ul_tag = PetSoup.findAll('div', {'class': 'group details-list'})
pet_details = [i.get_text() for i in ul_tag]
print(pet_details)
this gets me all of the items as one list object (I think) but I can't seem to parse it out so the I can assign variables to each item (e.g. Age:, Breed:, etc.)
['\n\nBreed: Chihuahua, Short Coat / Mix\nAge: 15y 5m Gender: Male\nColor: Black / Grey\nSpayed/Neutered: Yes\nSize: Small\nDeclawed: No\nAdoption Date: \n\n']
I've also tried:
for ultag in PetSoup.find_all('ul', {'class': 'group details-list'}):
for litag in ultag.find_all('li'):
print(litag.text)
which gets me all of the text, but again, can't seem to parse it to be able to assign variables
What I really want to do is just grab the text in the span tag but I can't seem to grab it. I think it has something to do with how the span tag is structured, but I can't seem to get it by trying different variations of items in the span. I just get an empty return. The specific span is:
<span data-bind="text: breed">Terrier, Rat / Mix </span>
Can anyone point me in the right direction? Thank you for your help! the specific page is here: https://www.petango.com/Adopt/Dog-Terrier-Rat-22192827