I'm getting KeyError trying to scrape data from website
问题 I wrote a code for data scraping; it works well for some pages, but for some it displays: KeyError: 'isbn'. Could you please guide me on how can I solve this issue? Here is my code: import requests import re import json from bs4 import BeautifulSoup import csv import sys import codecs def Soup(content): soup = BeautifulSoup(content, 'html.parser') return soup def Main(url): r = requests.get(url) soup = Soup(r.content) scripts = soup.findAll("script", type="application/ld+json", text=re