title: How can I loop a scrapy script?
body: <p>Scenario: I have a scrapy script which scrapes the site. Once the required keyword is found in the scraped detail, it'll send a mail. There is a site which changes data every 30 minutes, I need to scrape again after the specific keyword and send the email if found. How can I loop every 30 minutes in scrapy Python?</p>
  <p>Code:</p>
  <pre><code># -*- coding: utf-8 -*-
  import scrapy
  from scrapy.http import Request
  import smtplib
  from email.mime.text import MIMEText
  import time
  
  class NewFilmSpiderSpider(scrapy.Spider):
      name = 'new_film_spider'
      allowed_domains = ['www.xxx.in']
      start_urls = ['https://www.xxx.in/xxx/now-showing']
      
      def parse(self, response):
          t = threading.Thread(self.getDetails(response))
          t.start()
  
      def getDetails(self, response):
          FROM_ADDRESS = 'xxx@gmail.com'
          PASSWORD = 'xxx'
          TO_ADDRESS= 'xxx@gmail.com'
          HOST='smtp.gmail.com'
          PORT=587
          records = response.xpath('//section[@class=&quot;main-section&quot;]/section[2]/section[@class=&quot;movie__listing now-showing&quot;]/ul/li/div/dl/dt/a/text()').extract()
          if 'KEYWORD' in str(records):
              receivers = [TO_ADDRESS]
              msg=&quot;Booking Opened&quot;
              try:
                  smtpObj = smtplib.SMTP(HOST,PORT)
                  smtpObj.set_debuglevel(1)
                  smtpObj.ehlo()
                  smtpObj.starttls()
                  smtpObj.login(FROM_ADDRESS,PASSWORD)
                  smtpObj.sendmail(FROM_ADDRESS, receivers, msg)   
                  smtpObj.quit()      
                  print &quot;Successfully sent email&quot;
              except Exception as e:
                  print &quot;Error: unable to send email&quot;
           time.sleep(60) #checking for every minute
  </code></pre>
  <p>This code runs the script and sends the mail, but I don't know how to loop it.</p>