当我尝试将scrapy项目保存为json时,我会收到这样的错误:
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,那么它可以正常工作。我该怎么办?
答案 0 :(得分:0)
如果你想把你的物品输出为json,只需使用:
scrapy crawl spider -o output.json