コード例 #1
0
ファイル: wangyi.py プロジェクト: xiaogang00/web-crawler
 def db_has_exist(self, docid):
     sql = "select * from wangyi where docid='%s' and item_type='%s'" % (
         str(docid), self._item_type)
     if utils.query_mysql(sql):
         return True
     else:
         return False
コード例 #2
0
ファイル: wangyi.py プロジェクト: CN-P5/163spider
    def init_qsyk(self):
        """ 检查 run_control 表中 total 数据是否是0,如果不是,就运行程序,直到满足了 total 为止,并将 total 置为 0 """
        if self._need_init:
            sql = "select total, one_page from run_control where item='%s'" % (self._item_type)
            ret = utils.query_mysql(sql)

            total = 0
            one_page = 0
            if ret:
                total = int(ret[0]['total'])
                one_page = int(ret[0]['one_page'])

            if total > 0:
                for i in range(0, total, one_page):
                    self._start = i
                    self.download_and_insert()

                sql = "update run_control set total=0 where item='%s'" % (self._item_type)
                utils.update_mysql(sql)

            self._need_init = False
コード例 #3
0
ファイル: wangyi.py プロジェクト: xiaogang00/web-crawler
    def init_qsyk(self):
        """ 检查 run_control 表中 total 数据是否是0,如果不是,就运行程序,直到满足了 total 为止,并将 total 置为 0 """
        if self._need_init:
            sql = "select total, one_page from run_control where item='%s'" % (
                self._item_type)
            ret = utils.query_mysql(sql)

            total = 0
            one_page = 0
            if ret:
                total = int(ret[0]['total'])
                one_page = int(ret[0]['one_page'])

            if total > 0:
                for i in range(0, total, one_page):
                    self._start = i
                    self.download_and_insert()

                sql = "update run_control set total=0 where item='%s'" % (
                    self._item_type)
                utils.update_mysql(sql)

            self._need_init = False
コード例 #4
0
ファイル: wangyi.py プロジェクト: CN-P5/163spider
 def db_has_exist(self, docid):
     sql = "select * from wangyi where docid='%s' and item_type='%s'" % (str(docid), self._item_type)
     if utils.query_mysql(sql):
         return True
     else:
         return False