python bs4.element.Tag获取字典
如何将嵌套的“道具”作为字典python bs4.element.Tag获取字典,python,beautifulsoup,Python,Beautifulsoup,如何将嵌套的“道具”作为字典 from bs4 import BeautifulSoup import urllib.request url = urllib.request.urlopen('https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20201103&end=20201104').read() soup = BeautifulSoup(url, 'html.parser') foo = so
from bs4 import BeautifulSoup
import urllib.request
url = urllib.request.urlopen('https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20201103&end=20201104').read()
soup = BeautifulSoup(url, 'html.parser')
foo = soup.find('script', id="__NEXT_DATA__", type='application/json')
print ((foo))
使用
data=json.load(foo.contents[0])
print(data)
Solved。感谢您的及时回复@eyllanesc