I have the following script in Python but when the page loads the captcha does not work
Can someone help me?
On Windows I have this code that works well for me but on Linux it doesn't work for me
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)
How do I take it to seleniumbase and be able to obtain the data. I need help please.
When running the script with "xvfb-run python3 py3.py" it returns this error, This error is because the captcha has not been processed, so the RUT label does not exist
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 <module>
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!
I need help please. Thank you.
Xvfb :99 -screen 0 1920x1080x24 & python3 script.pyand in myscript.pyI set the display I'll will useos.environ["DISPLAY"] = ":99".