title: XPath/Scrapy scrape DOCTYPE
body: <p>Hi there guys and gals,</p>
  
  <p>I'm building a scraper using Scrapy and XPath. What I'm interested in scraping is the DOCTYPE from all of the sites that I traverse and I am having difficulty finding documentation regarding this and I feel as though it should be possible, given that it is a relatively simple request. Any suggestions?</p>
  
  <p>Cheers,</p>
  
  <p>Joey</p>
  
  <p>Here is the code that I have so far:</p>
  
  <pre><code>import scrapy
  from scrapy.selector import HtmlXPathSelector
  from scrapy.http import HtmlResponse
  from tutorial.items import DanishItem
  from scrapy.http import Request
  import csv
  
  
  class DanishSpider(scrapy.Spider):
    name = "dmoz"
    allowed_domains = []
    start_urls = [very long list of websites]
  
    def parse(self, response):
      for sel in response.xpath(???):
        item = DanishItem()
        item['website'] = response
        item['DOCTYPE'] = sel.xpath('????').extract()
        yield item
  </code></pre>
  
  <p>New spider, retrieves DOCTYPE but for some reason will print my response to the specified .json file 15 times as opposed to just once</p>
  
  <pre><code>class DanishSpider(scrapy.Spider):
    name = "dmoz"
    allowed_domains = []
    start_urls = ["http://wwww.example.com"]
  
    def parse(self, response):
      for sel in response.selector._root.getroottree().docinfo.doctype:
        el = response.selector._root.getroottree().docinfo.doctype
        item = DanishItem()
        item['website'] = response
        item['doctype'] = el
        yield item
  </code></pre>