old_contents: import clamd
  import requests
  import tempfile
  import shutil
  from contextlib import closing
  
  
  class NamedTemporaryDirectory(object):
      def __init__(self, *args, **kwargs):
          self.name = tempfile.mkdtemp(*args, **kwargs)
          self.closed = False
  
      def close(self):
          self.closed = True
          shutil.rmtree(self.name)
  
  
  def scan_html(url):
      with closing(NamedTemporaryDirectory(prefix="malucrawl_clamav-")) as temp_dir:
          """
          todo: should crawl the page, using lxml, and add all those pages to the directory
          then scan each page
          """
          with tempfile.NamedTemporaryFile(dir=temp_dir.name, delete=False) as html:
              response = requests.get(url, timeout=10.0)
              html.write(response.content)
  
          clamd.init_unix_socket()
          result = clamd.scan_file(temp_dir.name)
  
          return result
  
  if __name__ == "__main__":
      print scan_html("https://secure.eicar.org/eicar.com")
  
new_contents: import clamd
  import requests
  import tempfile
  import shutil
  from contextlib import closing
  
  clamd_socket = clamd.ClamdUnixSocket()
  
  
  class NamedTemporaryDirectory(object):
      def __init__(self, *args, **kwargs):
          self.name = tempfile.mkdtemp(*args, **kwargs)
          self.closed = False
  
      def close(self):
          self.closed = True
          shutil.rmtree(self.name)
  
  
  def scan_html(url):
      with closing(NamedTemporaryDirectory(prefix="malucrawl_clamav-")) as temp_dir:
          """
          todo: should crawl the page, using lxml, and add all those pages to the directory
          then scan each page
          """
          with tempfile.NamedTemporaryFile(dir=temp_dir.name, delete=False) as html:
              response = requests.get(url, timeout=10.0)
              html.write(response.content)
  
          result = clamd_socket.multiscan_file(temp_dir.name)
  
          return result
  
  if __name__ == "__main__":
      print scan_html("https://secure.eicar.org/eicar.com")
  
subject: use newer (2 years old) clamd 0.3.0 style api