0
我想弄清楚如何使用美丽的汤,我很难。美丽的汤解析HTML跨度
我的HTML页面有看起来像这样几个要素:
<a class="propertyName" href="/preferredguest/property/overview/index.html?propertyID=1023"><span>The Westin Peachtree Plaza, Atlanta
</span></a>
<a class="propertyName" href="/preferredguest/property/overview/index.html?propertyID=1144"><span>Sheraton Atlanta Hotel
</span></a>
我试图创建与酒店名称的数组。这是我的代码到目前为止:
import requests
from bs4 import BeautifulSoup
url = "removed"
response = requests.get(url)
soup = BeautifulSoup(response.text)
hotels = soup.find_all('a', class_="propertyName")
但我无法弄清楚如何迭代酒店数组显示span元素。