Hi Mukesh...
As i know you should add this thing in ur spider setting means in
setting.py,

ITEM_PIPELINES = {
#botname.pipelines.pipelineclassname
    'pagitest.pipelines.PagitestPipeline': 300,
}

after that you should write the code in pipeline.py


from twisted.enterprise import adbapi
import datetime
from scrapy import log
import MySQLdb.cursors

class PagitestPipeline(object):

    def __init__(self):
        self.dbpool = adbapi.ConnectionPool('MySQLdb', db='xyz',
                user='abc', passwd='bcd',
cursorclass=MySQLdb.cursors.DictCursor,
                charset='utf8', use_unicode=True)

    def process_item(self, item, spider):
        # run db query in thread pool
        query = self.dbpool.runInteraction(self._conditional_insert, item)
        query.addErrback(self.handle_error)

        return item

    def _conditional_insert(self, tx, item):
        # create record if doesn't exist.
        # all this block run on it's own thread
        tx.execute("select * from infosec where titlename = %s",
(item['titlename'][0], ))
        result = tx.fetchone()
        if result:
            log.msg("Item already stored in db: %s" % item, level=log.DEBUG)
        else:
            tx.execute(
                "insert into infosec (titlename, standname) "
                "values (%s, %s)",
                (item['titlename'][0],item['standname'][0],)
            )
            log.msg("Item stored in db: %s" % item, level=log.DEBUG)

    def handle_error(self, e):
        log.err(e)



On Wed, May 14, 2014 at 11:37 AM, Mukesh Salaria
<mukeshsalari...@gmail.com>wrote:

> hey guys
>
> Is someone know, how do we extract the images using scrapy with example as
> i am newbie.....
>
> --
> You received this message because you are subscribed to the Google Groups
> "scrapy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scrapy-users+unsubscr...@googlegroups.com.
> To post to this group, send email to scrapy-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/scrapy-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"scrapy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to scrapy-users+unsubscr...@googlegroups.com.
To post to this group, send email to scrapy-users@googlegroups.com.
Visit this group at http://groups.google.com/group/scrapy-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to