from pyvirtualdisplay import Display from selenium import webdriver from selenium.webdriver.common.by import By import time from datetime import datetime display = Display(visible=0, size=(800, 600)) display.start() browser = webdriver.Firefox() browser.get('https://platform.landlordinvest.com') browser.find_element(By.NAME, "email").send_keys('martinbrien@protonmail.com') browser.find_element(By.NAME,"password").send_keys('UZ&zyjCQ6p') browser.find_element(By.XPATH, "//button[1]").click() browser.get('https://platform.landlordinvest.com/invest/secondary-market') #Chrome('/home/martin/python/selenium/chromedriver') #browser.get('http://45.56.68.93/python/selenium/li/page_source_2023-06-16_02-22-38.html') #browser.get('http://45.56.68.93/python/selenium/li/page_source_2023-06-14_09-11-45.html') while True: browser.refresh() if browser.find_element(By.CLASS_NAME, "text-center").text == "Sale price": browser.find_element(By.LINK_TEXT,'View').click() timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S') file_name = f"page_source_{timestamp}.html" with open(file_name, 'w', encoding='utf-8') as file: file.write(browser.page_source) text=browser.find_element(By.CLASS_NAME,"text-center").text print(f"[{timestamp}] {text}") # print(browser.title) else: pass time.sleep(3) #print(browser.title) browser.quit() display.stop()