def test_XueqiuSpider(self): spider = XueqiuSpider() r = [] r = spider.results() self.assertGreater(len(r), 1000) if not isinstance(r[0], XueqiuStock): raise Exception('type error: result item is not Stock instance') dao = XueqiuDao('db.sqlite3', 'xueqiu') dao.update(r)
def test_XueqiuSpider(self): spider = XueqiuSpider() r = [] r = spider.results() self.assertGreater(len(r),1000) if not isinstance(r[0],XueqiuStock): raise Exception('type error: result item is not Stock instance') dao = XueqiuDao('db.sqlite3','xueqiu') dao.update(r)
def run(self): try: spider = XueqiuSpider(auto_perform=False) stock_ctrl_factory = StockCtrlFactory(self.setting) stock_ctrl = stock_ctrl_factory.create_stock_ctrl('xueqiu') spider.set_call_back(self) spider.perform() self.results = spider.results() stock_ctrl.update_by_result(self.results) self.succeed = True except Exception as e: self.succeed = False self.emit(QtCore.SIGNAL('except(const QString&)'), unicode(e))
def run(self): try: spider = XueqiuSpider(auto_perform=False) stock_ctrl_factory = StockCtrlFactory(self.setting) stock_ctrl = stock_ctrl_factory.create_stock_ctrl('xueqiu') spider.set_call_back(self) spider.perform() self.results = spider.results() stock_ctrl.update_by_result(self.results) self.succeed = True except Exception as e: self.succeed = False self.emit(QtCore.SIGNAL('except(const QString&)'),unicode(e))
def test_XueqiuDao_Update(self): spider = XueqiuSpider() ret = spider.results() dao = XueqiuDao('../db.sqlite3','xueqiu') dao.update(ret) self.assertEqual(len(ret),len(dao.all()))
def test_XueqiuDao_Update(self): spider = XueqiuSpider() ret = spider.results() dao = XueqiuDao('../db.sqlite3', 'xueqiu') dao.update(ret) self.assertEqual(len(ret), len(dao.all()))