Answer the question
In order to leave comments, you need to log in
Beautiful soup, how to get tag value by incomplete attribute value?
I need to get the text in a span tag by an incomplete class attribute value (because that part of the attribute value will change on the site).
Here is the code I have at the moment:
soup = BeautifulSoup(source.text, "html.parser")
Currency = soup.find_all('a', {"href": '/invest/currencies/USDRUB/'})
item = Currency[0]
Name = item.find("span", {"class": "NameColumn__nameWrapper_LWKdK"}).get_text() # Сдесь мне нужно чтобы не было LWKdK
item = Currency[2]
Price = item.find(("span", {"class": "Money-module__money_UwC2N"})).get_text() # А сдесь UwC2N
Answer the question
In order to leave comments, you need to log in
Import the module re: import re
And look like this:
Name = item.find("span", {"class": re.compile("Здесь частичный текст")}).get_text()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question