【发布时间】:2020-02-24 19:05:39
【问题描述】:
python noob here,我已经设法从 Wikipedia 上抓取了一份公司列表,如何将输出保存为 JSON 文件?
import requests
from bs4 import BeautifulSoup
import JSON
url = "https://en.wikipedia.org/wiki/List_of_companies_traded_on_the_JSE"
responce = requests.get(url)
soup = BeautifulSoup(responce.text, 'html.parser')
tables = soup.findAll('table', {'class':"wikitable sortable"})
for table in soup.find_all('table', {'class':"wikitable sortable"}):
print(table.text
【问题讨论】:
-
你应该使用
import json而不是JSON
标签: python json python-3.x beautifulsoup