0
結果:美しいスープはのfindAllからHTMLタグを削除し、私はこのコードを持っている
import requests
from bs4 import BeautifulSoup
url = "https://www.horoscope.com/us/horoscopes/general/horoscope-general-daily-today.aspx?sign=1"
page = requests.get(url)
soup = BeautifulSoup(page.text, "html.parser")
horoscope = soup.findAll("div", {"class": "block-horoscope-text f16 l20"}, text=True)
をしかし、返された結果は、同様のタグが含まれています。
<div class="block-horoscope-text f16 l20">
It could be scary for you to do anything risky for fear of conflict or failure, Aries. Perhaps you've tried to become invisible in different situations so you can avoid being noticed. These defense mechanisms may serve you for a while, but acting out of fear or guilt won't get you where you need to go. To achieve what you want, you must act with confidence, love, and faith.
</div>
どうすれば削除できますか?ご協力いただきありがとうございます。
これは機能します。ありがとう。 – CodesInTheValley
ようこそ:) @CodesInTheValley –
また、空白を削除したい場合は、 'print(str(horoscope).strip())' –