Очистка определенного текста td-класса, который появляется после задержкиPython

Программы на Python
Anonymous
 Очистка определенного текста td-класса, который появляется после задержки

Сообщение Anonymous »

Я не могу заставить программу извлечь текст из td class="number pp_2 bk_pp nowrap" с веб-страницы https://www.racingandsports.com.au/form ... anced-form. Что мне нужно, чтобы изменить текст на вкладке TFO?
Примечание: при загрузке веб-страницы происходит небольшая задержка, прежде чем числа появятся на вкладке TFO.
import requests
from bs4 import BeautifulSoup
import time

# URL of the webpage
url = "https://www.racingandsports.com.au/form ... anced-form"

# Fetch the webpage content
response = requests.get(url)

# Introduce a 8-second delay
time.sleep(8)

html_content = response.content

# Parse the HTML content
soup = BeautifulSoup(html_content, "html.parser")

# Find all td elements with class="number pp_2 bk_pp nowrap"
td_elements = soup.find_all("td", class_="number pp_2 bk_pp nowrap")

# Extract text from td elements and print
for td in td_elements:
print(td.text.strip())


Подробнее здесь: https://stackoverflow.com/questions/783 ... fter-delay

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