خرید بک لینک

Vote count: 0

I am following a tutorial to use pymongo

http://doc.scrapy.org/en/latest/topics/item-pipeline.html

I put the code in my file and it reports expected an indented block at line 8. Caot figure out why.

import pymongo

class MongoPipeline(object):

    collection_name = "post"

    def __init__(self, mongo_uri, mongo_db):
        self.mongo_uri = mongo_uri
        self.mongo_db = mongo_db

    @classmethod
    def from_crawler(cls, crawler):
        retu cls(
            mongo_uri = crawler.settings.get('MONGO_URI'),
            mongo_db = crawler.settings.get('MONGO_DATABASE', 'items'),
        )

    def open_spider(self, spider):
        self.client = pymongo.MongoClient(self.mongo_uri)
        self.db = self.client[self.mongo_db]

    def close_spider(self, spider):
        self.client.close()

    def process_item(self, item, spider):
        self.db[self.collection_name].insert(dict(item))
        retu item

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 7 ارديبهشت 1395 ساعت: 4:44

صفحه بندی