# 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

class FirstScrapyPipeline(object):
    def process_item(self, item, spider):
        return item

@@ -1,8 +1,31 @@
+# -*- coding:utf-8 -*-%0A
 # Define
@@ -188,101 +188,1036 @@
 ml%0A%0A
-class FirstScrapyPipeline(object):%0A    def process_item(self, item, spider):%0A        return item%0A
+%0Afrom scrapy import log%0Afrom twisted.enterprise import adbapi%0Afrom scrapy.http import Request%0Afrom scrapy.exceptions import DropItem%0Afrom first_scrapy.items import NewsItem%0Aimport time%0Aimport MySQLdb%0Aimport MySQLdb.cursors%0Aclass FirstScrapyPipeline(object):%0A    def process_item(self, item, spider):%0A        return item%0A%0A%0Aclass StartupNews(object):%0A%09%22%22%22docstring for StartupNews%22%22%22%0A%09def __init__(self):%0A%09%09self.dbpool=adbapi.ConnectionPool('MySQLdb',%0A%09%09%09host='127.0.0.1',%0A%09%09%09db='startupnews',%0A%09%09%09user='root',%0A%09%09%09passwd='111111',%0A%09%09%09cursorclass=MySQLdb.cursors.DictCursor,%0A%09%09%09charset='utf8',%0A%09%09%09use_unicode=True%0A%09%09%09)%0A%09def process_item(self,item,spider):%0A%09%09query=self.dbpool.runInteraction(self._insert,item)%0A%09%09query.addErrback(self.handle_error)%0A%0A%09def _insert(self,tx,item):%0A%09%09if item.get('title'):%0A%09%09%09#print item%5B'title'%5D,item%5B'link'%5D  insert into titles values (%22%E6%88%91%E6%93%A6%22,%22doubi%22)%0A%09%09%09query=%22insert into sites values(%5C%22%25s%5C%22,%5C%22%25s%5C%22)%22%25(item%5B'title'%5D,item%5B'link'%5D)%0A%09%09%09print query%0A%09%09%09tx.execute(query)%0A%0A%09def handle_error(self,e):%0A%09%09log.err(e)

add startupnews pipelines