Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

python 3.x - How to seperate two json files by string?

I am trying to parse a JSON from a website in order to extract some data. Somehow the JSON is "combined", meaning that the dataset for one product is described and without separating the next, the JSON simply continues. This throws an error in json.load (python3.8).

Here is the part in question:

"name": "30 stk"
                  }
              }
                      }                                               {
            "@type":"Product"

jsonlint outputs the following error:

Error: Parse error on line 126:
...30 stk"          }       }   } {     "@type": "Produc
--------------------^
Expecting 'EOF', '}', ',', ']', got '{'

Full JSON:

{"@context":"https://schema.org","@type":"Product","@id":"/antistax-extra-venentabletten-bei-venenleiden-60stk-pzn-00002335","aggregateRating":{"@type":"AggregateRating","ratingValue":"4,8","reviewCount":"26"},"description":"AntistaxextraVenentablettenbeiVenenleiden60stkkaufenbeiderOnlineApothekeapo-discounter.Medikamente,Nahrungserg?nzungenuvm.erhaltenSieinunsererVersandapothekezugünstigenPreisen.","name":"AntistaxextraVenentablettenbeiVenenleiden(60stk)","image":"https://www.apodiscounter.de/images/product_images/info_images/00002335_4.jpg","sku":"00002335","mpn":"00002335","productID":"00002335","category":"Venenerkrankung","brand":{"@type":"Organization","name":"Antistax"},"offers":{"@type":"Offer","availability":"https://schema.org/InStock","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenleiden-60stk-pzn-00002335","price":"27.49","priceValidUntil":"2021-01-26","priceCurrency":"EUR","category":"Filmtabletten","eligibleQuantity":"60stk","itemCondition":"NewCondition","seller":{"@type":"Organization","name":"apo-discounter.de"}},"issimilarto":[{"@type":"Product","mpn":"00002312","name":"AntistaxextraVenentablettenbeiVenenleiden","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenleiden-30stk-pzn-00002312","description":"AntistaxextraVenentablettenbeiVenenleiden30stkkaufenbeiderOnlineApothekeapo-discounter.Medikamente,Nahrungserg?nzungenuvm.erhaltenSieinunsererVersandapothekezugünstigenPreisen.","image":"https://www.apodiscounter.de/images/product_images/info_images/00002312.jpg","sku":"00002312","brand":{"@type":"Organization","name":"Antistax"},"aggregateRating":{"@type":"AggregateRating","ratingValue":"5,0","reviewCount":"13"},"review":[{"@type":"Review","author":"ErnaD.","datePublished":"30.10.2020","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"DomenicaZ.","datePublished":"04.09.2020","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"RitaS.","datePublished":"11.07.2020","description":"kaumwirksam","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"VerifizierterKunde","datePublished":"10.04.2020","description":"Binnichtganzüberzeugt","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"VerifizierterKunde","datePublished":"06.03.2020","description":"BinpositivüberraschtvondemProdukt","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}}],"offers":{"@type":"Offer","availability":"https://schema.org/InStock","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenleiden-30stk-pzn-00002312","price":"15.99","priceValidUntil":"2021-01-26","priceCurrency":"EUR","eligibleQuantity":{"@type":"QuantitativeValue","name":"30stk"}}}{"@type":"Product","mpn":"05954715","name":"AntistaxextraVenentablettenbeiVenenschw?che","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenschwaeche-90stk-pzn-05954715","description":"AntistaxextraVenentablettenbeiVenenschw?che90stkkaufenbeiderOnlineApothekeapo-discounter.Medikamente,Nahrungserg?nzungenuvm.erhaltenSieinunsererVersandapothekezugünstigenPreisen.","image":"https://www.apodiscounter.de/images/product_images/info_images/05954715.jpg","sku":"05954715","brand":{"@type":"Organization","name":"Antistax"},"aggregateRating":{"@type":"AggregateRating","ratingValue":"4,8","reviewCount":"167"},"review":[{"@type":"Review","author":"VerifizierterKunde","datePublished":"05.12.2020","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"RoswithaT.","datePublished":"23.11.2020","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"RalfZ.","datePublished":"22.11.2020","description":"Gutundpreiswert!","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"ReinhardS.","datePublished":"22.11.2020","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"VerifizierterKunde","datePublished":"08.11.2020","description":"WennmanProblememitVenenhatundlangeaufdenBeinenist,hilftesdenTagbesserzumeistern...","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}}],"offers":{"@type":"Offer","availability":"https://schema.org/InStock","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenschwaeche-90stk-pzn-05954715","price":"33.49","priceValidUntil":"2021-01-26","priceCurrency":"EUR","eligibleQuantity":{"@type":"QuantitativeValue","name":"90stk"}}},{"@type":"Product","mpn":"16156023","name":"AntistaxextraVenentablettenbeiVenenleiden&Venenschw?che","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenleiden-venenschwaeche-180stk-pzn-16156023","description":"AntistaxextraVenentablettenbeiVenenleiden&Venenschw?che180stkkaufenbeiderOnlineApothekeapo-discounter.Medikamente,Nahrungserg?nzungenuvm.erhaltenSieinunsererVersandapothekezugünstigenPreisen.","image":"https://www.apodiscounter.de/images/product_images/info_images/16156023.jpg","sku":"16156023","aggregateRating":{"@type":"AggregateRating","ratingValue":"5,0","reviewCount":"3"},"review":[{"@type":"Review","author":"IrinaL.","datePublished":"20.01.2021","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"AlfredS.","datePublished":"20.01.2021","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}},{"@type":"Review","author":"VerifizierterKunde","datePublished":"11.01.2021","description":"","name":"","reviewRating":{"@type":"Rating","bestRating":"5","ratingValue":"5","worstRating":"1"}}],"offers":{"@type":"Offer","availability":"https://schema.org/InStock","url":"https://www.apodiscounter.de/antistax-extra-venentabletten-bei-venenleiden-venenschwaeche-180stk-pzn-16156023","price":"56.49","priceValidUntil":"2021-01-26","priceCurrency":"EUR","eligibleQuantity":{"@type":"QuantitativeValue","name":"180stk"}}}],"review":[{"@type":"Review","author":"KlausS.","datePublished":"11.12.2020","description":"","name":"","reviewRating":{"@type":"Rating&q

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems you have a JSON array containing two JSON objects not separated by a comma.

You should just replace } { with }, {.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...