如何return 只从预订的酒店描述?

How to return only hotel description from booking?

如何仅打印来自 booking.com

的特定酒店的描述

例如:

我使用此代码但是 return None!

import requests
from scrapy.selector import Selector

url = 'https://www.booking.com/hotel/eg/mediterranean-azur.html?'

response2 = requests.get(url)

if response2.ok is True:
    selector = Selector(text=response2.content)
    print(selector.xpath("//div[@class='hp__hotel-name']").get())

有什么帮助吗?

试试这个:

import requests
from bs4 import BeautifulSoup

url = "https://www.booking.com/hotel/eg/mediterranean-azur.uk.html?"

r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
answ = soup.find("div", {"id":"property_description_content"}).text