Oct-12-2017, 02:49 PM
Hey guys!
I've been working on this script for a few days now. What it's supposed to do is go to a real estate listing page click on a listing, then click on the realtors personal website, and print out the URL THEN closing the window and returning back to the beginning of the loop. I ran in to an issue when the script came across a listing where the agent had no website which resulted in an error. I then tried using a try except which worked until the script hit the listing without an agent website. It would skip the listing and go back to the home page and close the whole browser. I got a solution off stackoverflow but now I get this issue:
Traceback (most recent call last):
File "/home/yxty/Realex.py", line 16, in <module>
WebDriverWait(driver, 15).until(lambda d: len(driver.window_handles) == 2)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Here is my code:
I've been working on this script for a few days now. What it's supposed to do is go to a real estate listing page click on a listing, then click on the realtors personal website, and print out the URL THEN closing the window and returning back to the beginning of the loop. I ran in to an issue when the script came across a listing where the agent had no website which resulted in an error. I then tried using a try except which worked until the script hit the listing without an agent website. It would skip the listing and go back to the home page and close the whole browser. I got a solution off stackoverflow but now I get this issue:
Traceback (most recent call last):
File "/home/yxty/Realex.py", line 16, in <module>
WebDriverWait(driver, 15).until(lambda d: len(driver.window_handles) == 2)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Here is my code:
time.sleep(15) for i in range(1,9): listing_page = driver.find_element_by_xpath('//*[@id="m_property_lst_cnt_realtor_more_'+str(i)+'"]').click() realtor_url = driver.find_elements_by_xpath('//*[@id="lblMediaLinks"]/a') if (len(realtor_url)) > 0: realtor_url[0].click WebDriverWait(driver, 15).until(lambda d: len(driver.window_handles) == 2) driver.switch_to_window(driver.window_handles[1]) driver.close() driver.switch_to_window(driver.window_handles[0]) driver.get(home_page) time.sleep(10)