Я использую следующее (все 64-бит):
- Firefox версия 135.0.1 < /li>
Geckodriver 0.36.0 < /li>
версия Python is 3.11.0
# Print the page source for debugging
with open('page_source.html', 'w', encoding='utf-8') as f:
f.write(driver.page_source)
print("Page source saved to 'page_source.html'.")
# Scroll to the bottom of the page
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2) # Wait for the table to load
# Wait for the table to load (increase timeout if needed)
try:
wait = WebDriverWait(driver, 20) # Wait up to 20 seconds
table = wait.until(EC.presence_of_element_located((By.ID, 'table-container-table')))
print("Table found!")
except Exception as e:
print(f"Table not found: {e}")
driver.quit()
exit()
# Find all rows in the table body
rows = table.find_elements(By.TAG_NAME, 'tr')
# Create a list to store the data
data = []
for row in rows:
cells = row.find_elements(By.TAG_NAME, 'td')
if len(cells) == 4: # Ensure there are 4 columns (SKU, Item Description, Platform, Value)
sku = cells[0].text
item_description = cells[1].text
platform = cells[2].text
value = cells[3].text
data.append({
'SKU': sku,
'Item Description': item_description,
'Platform': platform,
'Value': value
})
< /code>
Я получаю это сообщение об ошибке, когда запускаю свой код: < /p>
Page source saved to 'page_source.html'.
Table not found: Message:
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:197:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:527:5
dom.find/
Подробнее здесь: https://stackoverflow.com/questions/794 ... -a-website
Мобильная версия