0

Есть скрипт на Python, который парсит эту страницу: https://store.steampowered.com/app/268540/The_Whispered_World_Special_Edition/

Скрипт выводит тег html, в нём текст: 299 руб. Подскажите, как можно на выводе иметь тег не только со словом 229 руб., а вот так: Цена в Steam: 299 руб.

И так с любой игрой, не только с этой.

1 ответ 1

1

Воспользуйтесь replace_with.

def get_link(html):
    soup = BeautifulSoup(html, 'lxml')
    price = soup.find('div', class_='discount_original_price')
    if price is None:
        price = soup.find('div', class_='game_purchase_price price')
    price.string.replace_with('Цена в Steam: ' + price.string)
    print(price)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.