Веб-сайт Aeon не парсится. Другой работает нормально, кроме этого сайта [дубликат]Python

Программы на Python
Anonymous
Веб-сайт Aeon не парсится. Другой работает нормально, кроме этого сайта [дубликат]

Сообщение Anonymous »

Это код очистки
по какой-то причине он не очищает данные, хотя отображает сообщение о времени ожидания и не имеет никаких ошибок во время выполнения.
Я уже пробовал переключить поиск супа но все то же самое.
Ссылка на сайт: https://myaeon2go.com/products/category ... resh_foods
Изображение результата
Изображение

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
import time

def aeon_groceryitems():
chrome_options = Options()
chrome_options.add_argument("--headless")
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://myaeon2go.com/products/category ... resh_foods')
driver.maximize_window()

scroll_attempts = 10 # Limit the number of scroll attempts
last_height = driver.execute_script("return document.body.scrollHeight")

for _ in range(scroll_attempts):
# Scroll down to the bottom
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

# Wait to load the content
time.sleep(2) # Adjust website's loading time

# Calculate new scroll height and compare with last scroll height
new_height = driver.execute_script("return document.body.scrollHeight")

if new_height == last_height:
break # Break the loop if no new content is loaded

last_height = new_height

# 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.find_all('div', class_='nhQRizN1GA1WpbpCy_qn g-brand-text')
grocery_price = soup.find_all('span', class_='EgZI6WlRYJ4ErOBeOctF')

for item, price in zip(grocery_items, grocery_price):
item_name = item.get_text(strip=True)
item_price = price.get_text(strip=True)
print(f"Grocery Item: {item_name}")
print(f"Price: {item_price}")
print()

if __name__ == '__main__':
while True:
aeon_groceryitems()
time_wait = 10
print(f'Waiting {time_wait} minutes...')
time .sleep(time_wait * 60)


Подробнее здесь: https://stackoverflow.com/questions/788 ... -this-site

Вернуться в «Python»