直接上例子
# -*- coding: utf-8 -*-
#!/usr/bin/python3
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pymysql
from spiderman.env import *
class SpidermanPipeline(object):
def __init__(self):
self.conn = pymysql.connect(
host=dbhost,
user=dbuser,
password=dbpass,
db=dbname,
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
self.cursor = self.conn.cursor()
self.table = table_pool
self.filters = [
'测试',
'demo',
'pre-a',
'概念',
'天使',
'未',
'种子',
'不明确',
'上线