0

I am trying to access this URL, here I have to fetch table under Price / Tax History section. Below is my code:

from selenium import webdriver
from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import os, sys
from multiprocessing import Pool
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.support.ui import WebDriverWait

driver = webdriver.Firefox()
wait = WebDriverWait(driver, 5)
driver.maximize_window()
driver.get('https://www.zillow.com/homedetails/2114-Bigelow-Ave-N-Seattle-WA-98109/48749425_zpid/')
sleep(10)
p_history = driver.find_elements_by_css_selector('#tax-price-history  table tr > td')
    for p in p_history:
        print(p.text)

it is not printing text.

Update Screen of the section required:

enter image description here

Update#2

Ran against PhantomJS and here you can see loader image in the section(Scroll the image)

enter image description here

4
  • Can you try with the following query selector, note that it's not extensible and would work on only first row, for that you would need to do few more changes: document.querySelector('#tax-price-history tbody tr td:nth-child(3)') Commented Mar 20, 2017 at 10:48
  • @AnupamSaini First off, I am using Python, second I did try this and did not work Commented Mar 20, 2017 at 10:50
  • which text you are trying to fetch exactly, there are few td which doesn't have any text, they have span and some more span inside them and then text. Commented Mar 20, 2017 at 10:51
  • @GaurangShah Question updated. Commented Mar 20, 2017 at 10:59

1 Answer 1

2

You need to tell selenium to use WebDriverWait and expected_conditions to find the element once it's loaded.

You need a reference to an element that doesn't exist on page load, but should be there once the Ajax request is complete. It looks like #tax-price-history table should fulfil that requirement.

try:

from selenium.webdriver.support import expected_conditions as EC
parent = wait.until(EC.presence_of_element_located((
    By.CSS_SELECTOR, '#tax-price-history table')))

p_history = parent.find_element_by_css_selector('td')

If the element isn't found in the time limit specified in wait you'll get an error

Sign up to request clarification or add additional context in comments.

2 Comments

` value = method(self._driver)TypeError: 'list' object is not callable`
ah. the syntax is quite different in python. I'll edit the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.