old_contents: import pyclamd
  import urllib2
  
  
  def download_html(url):
      u = urllib2.urlopen(url, timeout=10.0)
      if (u == None):
          return None
      path = '/home/wl15g09/project/'
      fileName = 'file1.html'
      localFile = open(path + fileName, 'w+')
      localFile.write(u.read())
      localFile.close()
      return path + fileName
  
  
  def scan_html(url):
      html = download_html(url)
      if(html == None):
          return None
      else:
          pyclamd.init_unix_socket()
          result = pyclamd.scan_file(html)
          if (result == None):
              return 'No malicious content found.'
          else:
              return result
  
new_contents: import pyclamd
  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)
  
          pyclamd.init_unix_socket()
          result = pyclamd.scan_file(temp_dir.name)
  
          return result
  
  if __name__ == "__main__":
      print scan_html("https://secure.eicar.org/eicar.com")
  
subject: refactor clamav to be location independant