Example #1
0
 def do_insert(self, cursor, item):
     try:
         sql = "INSERT INTO image (image_id,image_from,image_title,category_code,create_time) " \
               "SELECT * FROM(SELECT %s image_id,%s image_from,%s image_title,%s category_code,NOW() create_time FROM DUAL) a " \
               "WHERE NOT EXISTS (SELECT image_id FROM image	WHERE image.image_id = a.image_id);"\
               "INSERT INTO image_url (image_id,image_url,image_name) VALUES (%s,%s,%s);"
         cursor.execute(
             sql,
             (item['image_id'], item['image_from'], item['image_title'],
              item['category_code'], item['image_id'], item['image_url'],
              item['image_title']))
     except Exception as e:
         log.msg("This is a ERROR ", level=log.ERROR)
         log.ERROR(e)
Example #2
0
 def parse_err(self, response):
     log.ERROR('crawl {} failed'.format(response.url))