G
G
GH0st_is_HAcker2021-09-05 19:50:59
Python
GH0st_is_HAcker, 2021-09-05 19:50:59

How to get rid of unnecessary tag (Beautifulsoup)?

Folks, I'm new to parsing and I can't seem to remove the wrong tag from this element

<a class="bui-link" href="/hotel/ua/nebo.uk.html?aid=376445&amp;label=slbn_-B9ObXm1VJOAq2ho0czzpIQS502774686655%3Apl%3Ata%3Ap1%3Ap22%2C563%2C000%3Aac%3Aap%3Aneg%3Afi3356467115%3Atikwd-65526620%3Alp1030451%3Ali%3Adec%3Adm%3Appccp%3DUmFuZG9tSVYkc2RlIyh9YTQUGSsRwx9_piJbnTYecvA&amp;sid=408e8bec19918cb9a956cc1d3c809af2&amp;dest_id=-1049092&amp;dest_type=city&amp;from_beach_non_key_ufi_sr=1&amp;group_adults=2&amp;group_children=0&amp;hapos=6&amp;hpos=6&amp;no_rooms=1&amp;sr_order=popularity&amp;srepoch=1630601820&amp;srpvid=a119772efbde00ce&amp;ucfs=1&amp;from=searchresults;map=1&amp;amp;msd=1#hotelTmpl" data-google-track="Click/Action: sr_map_link_used" data-coords="30.7358977943659,46.4734592264816" target="_blank" data-map-caption="" rel="noopener" data-et-click="customGoal:HZUaQRSeBcKHSYeGXT:1">
Приморський, Одеса
<span class="sr_card_address_line__item">
<span class="sr_card_address_line__dot-separator"></span>
Показати на карті</span>
</a>

I only need to get from this element ("Primorsky, Odessa"), but I don't need span here

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-09-05
@GH0st_is_HAcker

soup.find('a').find(text=True).strip()
Either through contents
soup.find('a').contents[0].strip()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question