code: def _url_to_epub(
              self):
          
          self.log.debug('starting the ``_url_to_epub`` method')
  
          from polyglot import htmlCleaner
          cleaner = htmlCleaner(
              log=self.log,
              settings=self.settings,
              url=self.urlOrPath,
              outputDirectory=self.outputDirectory,
              title=self.title,  # SET TO FALSE TO USE WEBPAGE TITLE,
              style=False,  # add simpdf's styling to the HTML document
              metadata=True,  # include metadata in generated HTML (e.g. title),
              h1=False  # include title as H1 at the top of the doc
          )
          html = cleaner.clean()
  
          if not html:
              return None
  
          if self.footer:
              footer = self._tmp_html_file(self.footer)
              footer = '"%(footer)s"' % locals()
          else:
              footer = ""
  
          if self.header:
              header = self._tmp_html_file(self.header)
              header = '"%(header)s"' % locals()
          else:
              header = ""
  
          # HTML SOURCE FILE
          epub = html.replace(".html", ".epub")
          pandoc = self.settings["executables"]["pandoc"]
  
          cmd = """%(pandoc)s -S -s -f html -t epub3 %(header)s '%(html)s' %(footer)s -o '%(epub)s' """ % locals(
          )
          p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
          stdout, stderr = p.communicate()
          self.log.debug('output: %(stdout)s' % locals())
  
          try:
              with open(epub):
                  pass
              fileExists = True
          except IOError:
              fileExists = False
              raise IOError(
                  "the epub %s does not exist on this machine, here is the failure message: %s" % (epub, stderr))
  
          os.remove(html)
  
          self.log.debug('completed the ``_url_to_epub`` method')
          return epub
docs: *generate the epub book from a URL*