【发布时间】:2021-12-01 12:44:41
【问题描述】:
如何使用 BeautifulSoup 获取data-amount 下的 JSON 数据?
这是我尝试过的:
import requests
from bs4 import BeautifulSoup
url = "https://azure.microsoft.com/en-au/pricing/details/managed-disks/"
response = requests.get(url)
table_doc = BeautifulSoup(response.text, "html.parser")
data = []
table = table_doc.find_all(
"table", attrs={"class": "data-table__table data-table__table--pricing"}
)[0]
table_body = table.find("tbody")
rows = table_body.find_all("tr")
for row in rows:
cols = row.find_all("td")
res = row.find("span", attrs={"class": "price-data"})
print(res)
【问题讨论】:
标签: python json beautifulsoup