本文整理汇总了Python中scrapy.exporters.JsonItemExporter方法的典型用法代码示例。如果您正苦于以下问题:Python exporters.JsonItemExporter方法的具体用法?Python exporters.JsonItemExporter怎么用?Python exporters.JsonItemExporter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy.exporters
的用法示例。
在下文中一共展示了exporters.JsonItemExporter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def __init__(self):
self.file = open('articleexport.json', 'wb')
self.exporter = JsonItemExporter(self.file, encoding="utf-8", ensure_ascii=False)
self.exporter.start_exporting()
示例2: spider_opened
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def spider_opened(self, spider):
file = open('/tmp/jobs.json', 'a+')
self.files[spider] = file
self.exporter = JsonItemExporter(file , encoding='utf-8', ensure_ascii=False)
self.exporter.start_exporting()
示例3: __init__
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def __init__(self):
self.file = open('anchar_export.json', 'wb')
self.exporter = JsonItemExporter(self.file, encoding="utf-8", ensure_ascii=False)
self.exporter.start_exporting()
示例4: __init__
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def __init__(self, spider_name):
self.file = open("output/{}_recipes.json".format(spider_name), 'wb')
self.file.write(
'{"date_scraped": "%s", "recipes": ' % datetime.datetime.now()
)
self.exporter = JsonItemExporter(self.file, encoding='utf-8',
ensure_ascii=False)
self.exporter.start_exporting()
示例5: spider_opened
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def spider_opened(self, spider):
file_json = open('%s_items.json' % spider.name, 'w+b')
self.files[spider] = file_json
self.exporter = JsonItemExporter(file_json)
self.exporter.start_exporting()
示例6: __init__
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def __init__(self):
self.file = open("books.json", 'wb')
self.exporter = JsonItemExporter(self.file, encoding='utf-8', ensure_ascii=False)
self.exporter.start_exporting()
示例7: __init__
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def __init__(self):
self.file = open('articleexport.json', 'wb')
self.exporter = JsonItemExporter(
self.file,
encoding="utf-8",
ensure_ascii=False
)
self.exporter.start_exporting()
示例8: __init__
# 需要导入模块: from scrapy import exporters [as 别名]
# 或者: from scrapy.exporters import JsonItemExporter [as 别名]
def __init__(self):
self.file = open('article.json','wb')
self.expo = JsonItemExporter(self.file,encoding='utf-8',ensure_ascii=False)
self.expo.start_exporting()