import requests
from bs4 import BeautifulSoup
url = 'https://www.airbnb.com/rooms/5711344'
html = requests.get(url)
soup = BeautifulSoup(html.text, 'html.parser')
divs = soup.find_all('div', attrs={'class': 'col-md-3 text-muted'})
for div in divs:
space = div.find('span').text.strip()
if space == "The Space":
print(space)
这对我很有用:我使用beauthoulsoup通过类属性获取div,然后循环查找正确的div。在
相关问题 更多 >
编程相关推荐