I am trying to access the People also ask panel content on the Google search results page for a given search and to extract the question and answer text of the presented questions. However, when I try to access the compound class, with browser.find_elements_by_class_name("_Tgc _s8w _y9e")
I get an error and I've tried to fix it by using browser.find_elements_by_class_name("._Tgc._s8w._y9e")
but then I get no results? I can't find out how else to access the HTML text, any help is much appreciated! Thank you!
Asked
Active
Viewed 81 times
0

zipzip12
- 41
- 1
- 6
-
Figured it out, for anyone else who comes across this question: – zipzip12 Jan 08 '18 at 02:27
-
browser.find_elements_by_xpath("//*[@class='_Tgc _s8w _y9e']") – zipzip12 Jan 08 '18 at 02:27
-
Possible duplicate of [Compound class names not permitted error Webdriver](https://stackoverflow.com/questions/32043877/compound-class-names-not-permitted-error-webdriver) – JeffC Jan 08 '18 at 04:06
-
You should probably post your own answer as the answer so others can benefit. – Daniel Jan 09 '18 at 04:26
1 Answers
0
Figured it out, for anyone else who comes across this question: browser.find_elements_by_xpath("//*[@class='_Tgc _s8w _y9e']")
by using xpath you can reference compound classes

zipzip12
- 41
- 1
- 6
-
This is not a safe solution. The DOM class attribute is a space-separated **list** of class names, and the order is not guaranteed. – SiKing Jan 10 '18 at 00:10