Guest User

Untitled

a guest
Dec 3rd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. class ScrapenewsPipeline(object):
  2.  
  3. def open_spider(self, spider):
  4. self.connection = psycopg2.connect(
  5. host= os.environ['HOST_NAME'],
  6. user=os.environ['USERNAME'],
  7. database=os.environ['DATABASE_NAME'],
  8. password=os.environ['PASSWORD'])
  9. self.cursor = self.connection.cursor()
  10. self.connection.set_session(autocommit=True)
  11.  
  12.  
  13. def close_spider(self, spider):
  14. self.cursor.close()
  15. self.connection.close()
  16.  
  17.  
  18. def process_item(self, item, spider):
  19. print ("Some Magic Happens Here")
  20.  
  21.  
  22. def checkUrlExist(self, item):
  23. print("I want to call this function from my spider to access the
  24. self.cursor variable")
Add Comment
Please, Sign In to add comment