title: Scrapy: Save response.body as html file?
body: <p>My spider works, but I can't download the body of the website I crawl in a .html file. If I write self.html_fil.write('test') then it works fine. I don't know how to convert the tulpe to string.</p>
  
  <p>I use Python 3.6</p>
  
  <p><strong>Spider:</strong></p>
  
  <pre><code>class ExampleSpider(scrapy.Spider):
      name = "example"
      allowed_domains = ['google.com']
      start_urls = ['http://google.com/']
  
      def __init__(self):
          self.path_to_html = html_path + 'index.html'
          self.path_to_header = header_path + 'index.html'
          self.html_file = open(self.path_to_html, 'w')
  
      def parse(self, response):
          url = response.url
          self.html_file.write(response.body)
          self.html_file.close()
          yield {
              'url': url
          }
  </code></pre>
  
  <p><strong>Tracktrace:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "c:\python\python36-32\lib\site-packages\twisted\internet\defer.py", line
   653, in _runCallbacks
      current.result = callback(current.result, *args, **kw)
    File "c:\Users\kv\AtomProjects\example_project\example_bot\example_bot\spiders
  \example.py", line 35, in parse
      self.html_file.write(response.body)
  TypeError: write() argument must be str, not bytes
  </code></pre>