Нет необходимости использовать Selenium
, поскольку желаемый контент доступен в исходном коде без включенного javascript, поэтому мы можем использовать BeautifulSoup
, то есть:
from bs4 import BeautifulSoup as bs
import requests
mod = "erc"
brand = "Kyocera"
model = "TASKalfa+2460ci"
# get total pages
u = f"https://printcopy.info/?mod={mod}&brand={brand}&model={model}"
soup = bs(requests.get(u).text, "html5lib")
# find the total number of pages
pages = int([i.findAll('option') for i in soup.findAll('select', {"id": "selectNumPages"} )][0][-1].text) + 1
# print(pages)
for page in range(1, pages):
u = f"https://printcopy.info/?mod={mod}&brand={brand}&model={model}&page={page}"
soup = bs(requests.get(u).text, "html5lib")
ercRow = soup.findAll("ul", {"class": "ercRow"})
for ul in ercRow:
lis = ul.findAll("li")
code = lis[0].text.strip("Code: ")
description = lis[1].text.strip("Description: ")
causes = lis[2].text.strip("Causes: ")
remedy = lis[3].text.strip("Remedy: ")
print(code, description, causes, remedy, sep="\n")
# insert the values on db...
Выход:
C0070
FAX PWB incompatible detection error
Abnormal detection of FAX control PWB incompatibility in the initial communication with the FAX control PWB, any normal communication command is not transmitted.
1 Checking the FAX PWB The incompatible FAX PWB is installed. Install the FAX PWB for the applicable model. 2 Firmware upgrade The FAX firmware is faulty. Reinstall the FAX firmware. 3 Replacing the main PWB The main PWB is faulty. Replace the main PWB.
C0100
Backup memory device error
An abnormal status is output from the flash memory.
1 Resetting the main power The flash memory does not operate properly. Turn off the power switch and unplug the power plug. After 5s passes, reconnect the power plug and turn on the power switch. 2 Checking the main PWB The connector or the FFC is not connected properly. Or, the wire, FFC, the PWB is faulty. Clean the terminal of the connectors on the main PWB, reconnect the connector of the wire, and reconnect the FFC terminal. If the wire or the FFC is faulty, repair or replace them. If not resolved, replace the main PWB.
...