Я создаю сайт сравнения цен для своего университетского проекта. Я пытаюсь распечатать товары и цены с этого сайта https://www.lotuss.com.my/en/category/f ... vance:DESC, но получил эту ошибку.
Exception has occurred: TypeError
'NoneType' object is not callable
File "C:\xampp\htdocs\Price\test.py", line 36, in
grocery_items = soup.findall('div', class_='product-grid-item')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable
Это код
from bs4 import BeautifulSoup
import requests
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
service = Service(executable_path='C:/chromedriver/chromedriver.exe')
driver = webdriver.Chrome(service=service, options=chrome_options)
# Open the webpage
driver.get('https://www.lotuss.com.my/en/category/f ... vance:DESC')
# Wait for the page to fully load
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "iframe"))
)
print("Please solve the CAPTCHA manually in the opened browser window.")
finally:
input("Press Enter after solving the CAPTCHA...")
html_text = driver.page_source
driver.quit()
soup = BeautifulSoup(html_text, 'lxml')
grocery_items = soup.findall('div', class_='product-grid-item')
grocery_price = soup.findall('span', class_='sc-kHxTfl hwpbzy')
print(grocery_items)
print(grocery_price)
Подробнее здесь: https://stackoverflow.com/questions/788 ... utifulsoup