def schedule_crawl(self, crawler, spider, schedule): with session.begin(): crawler = session.query(Crawler).filter_by(id=crawler).first() spider = session.query(Spider).filter_by(crawler_id=crawler.id, name=spider).first() crawl_schedule = CrawlSchedule(spider_id=spider.id, crontab=schedule) session.add(crawl_schedule)
def add_egg(self, crawler, version, egg_handle): with session.begin(): crawler = session.query(Crawler).filter_by(id=crawler).first() crawler.egg = egg_handle.read() crawler.version = version session.add(crawler)
def get_crawler(self, crawler_id): with session.begin(): return session.query(Crawler).filter_by(id=crawler_id).first()