本文整理匯總了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()