Я использую следующее (все 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/
Вот копия внутреннего HTML таблицы-container: < /p>
Search:
SKU
Item Description
Platform
Values
702645
RAINBOW 6 SEIGE PS4
Playstation 4
$5.00
709782
NEED FOR SPEED:RIVALS PS4
Playstation 4
$8.00
709809
SYS-PS4 500GB Console
Playstation 4
$50.00
709823
ASSASSINS CREED IV PS4
Playstation 4
$6.00
709833
ASSASSINS CREED IV XB1
Xbox One
$3.00
709843
JUST DANCE 2014 XB1
Xbox One
$3.00
709847
JUST DANCE 2014 PS4
Playstation 4
$3.00
709871
FORZA MOTORSPORT 5 XB1
Xbox One
$3.00
709878
COD:GHOSTS XB1
Xbox One
$3.00
709880
COD: GHOSTS PS4
Playstation 4
$4.00
Showing 1 to 10 of 5,378 entries
< /code>
Вот копия внешнего HTML: < /p>
Search:
SKU
Item Description
Platform
Values
702645
RAINBOW 6 SEIGE PS4
Playstation 4
$5.00
709782
NEED FOR SPEED:RIVALS PS4
Playstation 4
$8.00
709809
SYS-PS4 500GB Console
Playstation 4
$50.00
709823
ASSASSINS CREED IV PS4
Playstation 4
$6.00
709833
ASSASSINS CREED IV XB1
Xbox One
$3.00
709843
JUST DANCE 2014 XB1
Xbox One
$3.00
709847
JUST DANCE 2014 PS4
Playstation 4
$3.00
709871
FORZA MOTORSPORT 5 XB1
Xbox One
$3.00
709878
COD:GHOSTS XB1
Xbox One
$3.00
709880
COD: GHOSTS PS4
Playstation 4
$4.00
Showing 1 to 10 of 5,378 entries
Подробнее здесь: https://stackoverflow.com/questions/794 ... -a-website
Мобильная версия