Может ли кто-нибудь мне помочь?
В Windows я есть этот код, который у меня хорошо работает, но в Linux он не работает
Код: Выделить всё
import json
from seleniumbase import SB
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://www.nombrerutyfirma.com/"
sb.activate_cdp_mode(url)
sb.sleep(2)
cf_shadow = '[style="display: grid;"] div div'
if sb.is_element_visible(cf_shadow):
sb.cdp.gui_click_element(cf_shadow)
sb.sleep(2)
sb.open(url)
sb.wait_for_element('body', timeout=15)
sb.click('a[href="#rut"]')
rut_input = sb.wait_for_element_visible('div#rut input[name="term"]', timeout=10)
rut_input.send_keys("21.405.338-1")
rut_input.send_keys("\ue007")
rows = sb.wait_for_elements('table.table-hover tbody tr', timeout=10)
data = []
for row in rows:
columns = row.find_elements('td')
record = {
"Nombre": columns[0].text,
"RUT": columns[1].text,
"Sexo": columns[2].text,
"Dirección": columns[3].text,
"Ciudad/Comuna": columns[4].text,
}
data.append(record)
json_data = json.dumps(data, ensure_ascii=False, indent=4)
print(json_data)
При запуске сценария с «xvfb-run python3 py3.py» он возвращает эту ошибку. Эта ошибка связана с тем, что капча не была обработана, поэтому ярлыка РУТ не существует
Код: Выделить всё
Haciendo clic en el tab de 'RUT'...
Traceback (most recent call last):
File "/usr/local/lib/python3.12/dist-packages/seleniumbase/plugins/sb_manager.py", line 1223, in SB
yield sb
File "/home/scripts_python/py3.py", line 25, in
sb.click('a[href="#rut"]')
File "/usr/local/lib/python3.12/dist-packages/seleniumbase/fixtures/base_case.py", line 395, in click
self.cdp.click(selector, timeout=timeout)
File "/usr/local/lib/python3.12/dist-packages/seleniumbase/core/sb_cdp.py", line 633, in click
element = self.find_element(selector, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/seleniumbase/core/sb_cdp.py", line 165, in find_element
raise Exception(message)
Exception:
Element {a[href="#rut"]} was not found after 7 seconds!
Подробнее здесь: https://stackoverflow.com/questions/793 ... nux-ubuntu