0

Hi I'm trying to scrape an ecommerce store 'konga.com' with selenium but when I try to get all the elements with with common class name, I get '0' response and some error. here's my code

from selenium import webdriver

import time

from selenium.webdriver.chrome.service import Service

from selenium.webdriver.common.by import By

url = 'https://www.konga.com/search?search=IPHONES'


service = Service(executable_path="C:/driver/chromedriver_win32/chromedriver.exe")

driver = webdriver.Chrome(service=service)

driver.get(url)

time.sleep(10)

driver.maximize_window()


product_cards = driver.find_elements(By.CLASS_NAME, 'bbe45_3oExY _22339_3gQb9')

time.sleep(10)
print(len(product_cards))

Here's the error I get:

DevTools listening on ws://127.0.0.1:56835/devtools/browser/958d5a8b-268b-4699-8d41-fcd315cbb155

0

[12544:708:1027/102731.294:ERROR:gpu_init.cc(521)] Passthrough is not supported, GL is disabled, ANGLE is 

[5080:11512:1027/102831.450:ERROR:util.cc(129)] Can't create base directory: C:\Program Files (x86)\Google\GoogleUpdater
Miracle
  • 89
  • 7

1 Answers1

1

By.CLASS_NAME searches for one class at a time. This element you are looking for has two classes: bbe45_3oExY and _22339_3gQb9. Class names are separated by space inside the class attribute.
So in this case you can get the result you want using the command driver.find_elements(By.CLASS_NAME, 'bbe45_3oExY')

And concerning the question about the errors there is a post here

Eugeny Okulik
  • 1,331
  • 1
  • 5
  • 16
  • 1
    HI @Eugeny thanks for the answer. It worked. Now concerning the error message, disabling hardware accelerator still didn't solve any of those errors. I googled how to disable software rasterizer to check if it could work but couldn't find any clear path to that. I wish there are more ways to stop those two errors. thanks. –  Miracle Oct 27 '22 at 13:57
  • To be honest, I have not encountered this, but I know that there are some errors that are almost impossible to fix. But these errors do not interfere with code execution. In such situations, people somehow disable or configure logging for selenium. Well, or they don't pay attention to these errors at all. – Eugeny Okulik Oct 27 '22 at 14:40
  • Yeah they are not show stoppers but they make my console look untidy and hard to read. Thanks for the help anyways –  Miracle Oct 27 '22 at 15:06