title: I want to download the contents of table after giving search criteria into a file in html format using selenium webdriver with python
body: <p>I want to download the contents of table after giving search criteria into a file in html format using selenium webdriver with python.</p>
  
  <p><a href="https://www.tis.bizfile.gov.sg//ngbtisinternet/faces/oracle/webcenter/portalapp/pages/productlisting/ishopProductListing.jspx?EntityNo=201228154Z&amp;producttype=ALL&amp;_afrLoop=163347378044200&amp;_afrWindowMode=0&amp;_afrWindowId=1kqsaugkt_6#%40%3F_afrWindowId%3D1kqsaugkt_6%26_afrLoop%3D163347378044200%26EntityNo%3D201228154Z%26producttype%3DALL%26_afrWindowMode%3D0%26_adf.ctrl-state%3D1kqsaugkt_38" rel="nofollow noreferrer">URL to the content table:</a></p>
  
  <p>at end of page in Extracts, i gave Transcation Date as Last 1 year and clicked Find button.</p>
  
  <p>this gives a new table. i want to download the contents of table into a file as html format.</p>
  
  <p>this is my code</p>
  
  <p>from datetime import datetime</p>
  
  <pre><code>from dateutil.parser import parse
  import time
  import requests
  from lxml import html
  from time import time
  
  
  def get_master_data(uen):
      crawler_tracker = None
      start_time = time()
  
      din = []
      master_data = {
      'uen':'',
      'directors':[]
      }
  
      p = open("/home/termsheet/Desktop/practo2.html","r")
      str_text = p.read()
  
      tree = html.fromstring(str_text)
  
      if not (tree.xpath('//form[@id="f1"]')):
      raise "f1 form not found"
  
      return
  
      if (tree.xpath('//form[@id="f1"]')):
      print('//form[@id="f1"]')
  
  
      if tree.xpath('//*[@id="pt1:r1:s33:plam1"]/td[2]/span'):
          uen = tree.xpath('//*[@id="pt1:r1:s33:plam1"]/td[2]/span/text()')[0]
          master_data['uen'] = uen
          print( "UEN: "+ uen)
  
      if tree.xpath('//*[@id="pt1:r1:s33:plam3"]/td[2]/span'):
          Status = tree.xpath('//*[@id="pt1:r1:s33:plam3"]/td[2]/span/text()')[0]
          print( "Status: "+ Status)
  
      if tree.xpath('//*[@id="pt1:r1:s33:pgl249"]/div[1]/span'):
          Address = tree.xpath('//*[@id="pt1:r1:s33:pgl249"]/div/span/text()')
          final = Address[0]+','+Address[1]+','+Address[2]
          last_line = tree.xpath('//*[@id="pt1:r1:s33:pgl228"]/tbody/tr/td[1]/span/text()')[0]
          print("Address: "+final)
          print(last_line)
  
  
  
  
  get_master_data("201228154Z")
  
  
  
  from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import Select
  from selenium.webdriver.common.action_chains import ActionChains
  import codecs
  import xml.dom.minidom
  import time
  
  class Acra():
  
      driver = webdriver.Chrome()
      #driver = webdriver.Chrome(executable_path = "/usr/lib/chromium-browser/chromedriver.exe")
      base_url = "https://www.tis.bizfile.gov.sg/"
      driver.get(base_url+ "/ngbtisinternet/faces/oracle/webcenter/portalapp/pages/productlisting/ishopProductListing.jspx?EntityNo=201228154Z&amp;producttype=ALL&amp;_afrLoop=163347378044200&amp;_afrWindowMode=0&amp;_afrWindowId=1kqsaugkt_6#%40%3F_afrWindowId%3D1kqsaugkt_6%26_afrLoop%3D163347378044200%26EntityNo%3D201228154Z%26producttype%3DALL%26_afrWindowMode%3D0%26_adf.ctrl-state%3D1kqsaugkt_38")
      s=Select(driver.find_element_by_id("pt1:r1:s33:soc1::content")).select_by_visible_text("Last 1 Year")
      driver.find_element_by_css_selector("option[title=\"Last 1 Year\"]").click()
      driver.find_element_by_id("pt1:r1:s33:cb4").click()
      time.sleep(10)
  
  
  
  
  Acra()
  </code></pre>