2016-07-31 57 views
0

當我嘗試保存scrapy項目,如JSON我得到的錯誤是這樣的:無法序列scrapy項目

TypeError: {'commitment': u'6 hrs/total', 


'course_id': 5098, 
'course_image_url': u'https://instructure-gallery.s3.amazonaws.com/production/products/965fe31a3fd1817ac9bec2d1628c8a62263341ac-thumb.jpg?1464928700', 
'course_type': u'Course', 
'credential': u'None', 
'date': u'Self-paced', 
'description_html': [u'<div class="main-column col-md-8">\n\t\t<h3>Description</h3>\n\t\t<p>Now that you\u2019re effectively blending/personalizing your own classroom, it\u2019s 
time for you to take the next step to become a blended leader and share your work with your school, district, and community. This course provides tools to help you begin that pr 
ocess, including:\n</p>\n<ul>\n<li>Case studies featuring schools that have started to extend their blending\n</li><li>Resources to start building your skill set as a blended lea 
der\n</li><li>Tips to focus your future goals and build action steps today\n</li><li>Suggestions for conferences to attend\n</li><li>Examples for using social media to improve an 
d share your practice\n</li><li>Ways to engage teachers and parents in this work</li></ul>\n\n\n\t\t<h3>Objectives</h3>\n\t\t<p>In this course, participants will:</p><ul>\n<li>Ex 
plore resources to build skills to become a blended leader and extend their reach.\n</li><li>Put together a timeline of their current blended journeys and future goals, including 
action steps to extend blending in their schools and/or communities. </li>\n\n\n\t</ul></div>'], 
'duration': u'Ongoing', 
'instructors': {'bio': u'Juliana Finegan is the Director of Personalized Learning at Relay Graduate School of Education. With support from TLA, Juliana, a former classroom teach 
er, developed four courses that support teachers and leaders to shift to blended and personalized learning models. Juliana has observed best practices all over the country, captu 
red strong blended footage, identified common denominators of implementation, and named key strategies that can be used immediately.', 
'image_url': u'http://pub-images.canvasnetwork.com/CN-2108-headshot-Juliana-Finegan.jpg', 
'name': u'Juliana Finegan', 
'subtitle': u'Professor'}, 
'is_free': True, 
'name': u'BL-201: Extending Your Blending', 
'organisation_image_url': u'https://instructure-gallery.s3.amazonaws.com/production/logos/b69b743bccd600578078628d50f8af69b088d39b.jpg?1465424854', 
'organisation_name': u'Relay Graduate School of Education', 
'price': u'$0', 
'requirement': u'None', 
'short_description': u'You\u2019re currently blending your curriculum and have seen how personalization helps push student growth, agency, engagement, and much more. Now it\u201 
9s your turn to start sharing your best practices, become a blended leader, and extend your reach.', 
'spider': 'canvas', 
'url': u'http://www.canvas.net/browse/relay/courses/extending-your-blending'} is not JSON serializable 

但是,如果我把它說,字典是不是從錯誤日誌序列化和做json.dumps在它上面,然後它完美地工作。我該怎麼辦?

+1

似乎是默認的Python的默認'json'模塊是有點笨這裏。我用'demjson'試過了,它工作正常。它似乎與嵌套字典有關。 – Granitosaurus

+0

謝謝!使用demjson工作。 – vigenere

回答

0

如果你想輸出中的項目,如JSON只需使用:

scrapy crawl spider -o output.json 
+0

我僅在執行此操作時遇到此錯誤 – vigenere