code: def linked_headlines(self, response, site_dict, check_self=False):
          
          h_all = 0
          h_linked = 0
          domain = UrlExtractor.get_allowed_domain(site_dict["url"], False)
  
          # This regex checks, if a link containing site_domain as domain
          # is contained in a string.
          site_regex = r"href=[\"'][^\/]*\/\/(?:[^\"']*\.|)%s[\"'\/]" % domain
          for i in range(1, 7):
              for headline in response.xpath('//h%s' % i).extract():
                  h_all += 1
                  if "href" in headline and (
                              not check_self or re.search(site_regex, headline)
                          is not None):
                      h_linked += 1
  
          self.log.debug("Linked headlines test: headlines = %s, linked = %s",
                         h_all, h_linked)
  
          min_headlines = self.cfg_heuristics["min_headlines_for_linked_test"]
          if min_headlines > h_all:
              self.log.debug("Linked headlines test: Not enough headlines "
                             "(%s < %s): Passing!", h_all, min_headlines)
              return True
  
          return float(h_linked) / float(h_all)
docs: Checks how many of the headlines on the site contain links.
  
          :param obj response: The scrapy response
          :param dict site_dict: The site object from the JSON-File
          :param bool check_self: Check headlines/
                                  headlines_containing_link_to_same_domain
                                  instead of headline/headline_containing_link
  
          :return float: ratio headlines/headlines_containing_link