Felipe Mezzarana
Felipe Mezzarana

Reputation: 97

Get specifc element with BeautifulSoup

So, I have this html structure in a bs4.BeautifulSoup:

<div class="bordered radius border-color-ui-2 bg-white h-100">
  <a href="#" class="box-card-link-wishlist" role="button" aria-label="Adicionar Central Multimídia Pósitron SP8730DTV LCD 6,2&amp;quot; TV Entrada para Câmera de Ré USB Bluetooth aos favoritos">
   <i class="icon icon_wishlist txt-body-lg pointer r-0 t-0 card-wishlist pos-absolute" alt="icon_wishlist" aria-hidden="true">

And I need to get the aria-label :

"Adicionar Central Multimídia Pósitron SP8730DTV LCD 6,2&amp;quot; TV Entrada para Câmera de Ré USB Bluetooth aos favoritos"

Looks like an easy task, but I tried everthing and nothing works. I don't even need to get the exact text, if the phrase is inside some text i can use regex to retrieve what I want..

Some exemples of what I tried:

names = bs.find_all('div'{'class':'bordered radius border-color-ui-2 bg-white h-100'})

names = bs.find_all('div'{'class':'box-card-link-wishlist'})

names = bs.find_all('a'}) 

names = bs.find_all('a',href = True})

names = bs.select('a[aria-label]')

names = bs.find_all('button'}) 

Upvotes: 0

Views: 48

Answers (1)

Felipe Mezzarana
Felipe Mezzarana

Reputation: 97

Thanks for the answers, but my problem was that the element really wasn't appearing. Since I was using selenium, the default windows size caused the problem, because the element that I needed only appear with a wider windows.

adding the argument:

op.add_argument('window-size=1200,1100')

Solved my problem.

Upvotes: 1

Related Questions