1

I am trying to scrape a google webpage for the title inside a td, this is the code I have got so far but I am missing something.

from selenium import webdriver

case_url = "http://www.google.com/finance?q=NYSE%3Acalm&ei=7DIoVcKZNo2ZjALz8YCYCw"


driver = webdriver.Firefox()
driver.get(case_url)

elem = driver.find_element_by_class_name("ctsymbol")

print(elem[1])

assert "No results found." not in driver.page_source

driver.close()

#

the class as seen on the browser is as follow:

IBA

Help!!

1 Answer 1

2

There are eleven elements with this class. The method you're using, find_element_by_class_name, only returns one element. So with elem[1] you're asking for an element in a list, that's not actually a list.

If you want to have a list of all elements with this class, use find_elements_by_class_name - see http://selenium-python.readthedocs.org/en/latest/locating-elements.html for the difference.

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

Comments

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.