Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ScrapenewsPipeline(object):
- def open_spider(self, spider):
- self.connection = psycopg2.connect(
- host= os.environ['HOST_NAME'],
- user=os.environ['USERNAME'],
- database=os.environ['DATABASE_NAME'],
- password=os.environ['PASSWORD'])
- self.cursor = self.connection.cursor()
- self.connection.set_session(autocommit=True)
- def close_spider(self, spider):
- self.cursor.close()
- self.connection.close()
- def process_item(self, item, spider):
- print ("Some Magic Happens Here")
- def checkUrlExist(self, item):
- print("I want to call this function from my spider to access the
- self.cursor variable")
Add Comment
Please, Sign In to add comment