在没有标签的网页中使用 BeautifulSoup 的 findAll 函数

Use findAll function of BeautifulSoup in webpages without tags

我正在使用 BeautifulSoup 进行练习,我正在尝试提取该网站的“可用”部分:https://api.meitre.com/api/calendar-availability-new/154/2/dinner

鉴于上面没有任何标签,我似乎找不到路。

在这种情况下如何使用 findall 函数?有可能吗?

提前致谢!

正如@Jon Clements 提到的那样,url 生成 json 数据并获取 json 数据,您可以按照下一个示例进行操作。

import requests
import json

data = requests.get('https://api.meitre.com/api/calendar-availability-new/154/2/dinner').json()

# jsn_data = json.dumps(data)
# with open('data.json','w') as f:
#     f.write(jsn_data)

for item in data['calendarInfo']:
    date = item['date']
    available = item['type']

    print(date)

输出:

2022-03-02T00:00:00-03:00
2022-03-03T00:00:00-03:00
2022-03-04T00:00:00-03:00
2022-03-05T00:00:00-03:00
2022-03-08T00:00:00-03:00
2022-03-09T00:00:00-03:00
2022-03-10T00:00:00-03:00
2022-03-11T00:00:00-03:00
2022-03-12T00:00:00-03:00
2022-03-15T00:00:00-03:00
2022-03-16T00:00:00-03:00
2022-03-17T00:00:00-03:00
2022-03-18T00:00:00-03:00
2022-03-19T00:00:00-03:00
2022-03-22T00:00:00-03:00
2022-03-23T00:00:00-03:00
2022-03-24T00:00:00-03:00
2022-03-25T00:00:00-03:00
2022-03-26T00:00:00-03:00
2022-03-29T00:00:00-03:00
2022-03-30T00:00:00-03:00
2022-03-31T00:00:00-03:00
2022-04-01T00:00:00-03:00
2022-04-02T00:00:00-03:00