使用漂亮的汤(BeautifulSoup)从booking.com上抓取价格,可以按照以下步骤进行:
import requests
from bs4 import BeautifulSoup
url = "https://www.booking.com"
response = requests.get(url)
html_content = response.text
soup = BeautifulSoup(html_content, "html.parser")
price_element = soup.find("span", class_="price")
price = price_element.text
print("The price on booking.com is: " + price)
需要注意的是,以上代码仅为示例,实际应用中可能需要根据booking.com页面的具体结构进行相应的调整。
推荐的腾讯云相关产品:腾讯云服务器(CVM)和腾讯云数据库(TencentDB)。
领取专属 10元无门槛券
手把手带您无忧上云