S
S
san_m_m2021-10-15 19:09:03
Python
san_m_m, 2021-10-15 19:09:03

How to fix the parser?

Good afternoon!

Wrote the following parser.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from tqdm.auto import tqdm


inn, datas, namess = [], [], []


def import_dates(name, inn):
    search_name = driver.find_element_by_name('userFullName')
    search_name.send_keys(name)
    search_inn = driver.find_element_by_name('documentNumber')
    search_inn.send_keys(inn) 
    
    
    try:
        button_close = driver.find_element_by_xpath("//button[@title = 'Закрыть']") #ВОТ на этом этапе все перестает работать. Попробовал и по классу и по xpath никак не могу закрыть виджет
        button_close.click()  
        button = driver.find_element_by_tag_name('button.form__button-submit.btn--basic')
        button.click()   
    except:
        button = driver.find_element_by_tag_name('button.form__button-submit.btn--basic')
        button.click()        
        
    try:
        table = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.TAG_NAME, "div.wrapper.block-content"))
        ).text
        names = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.TAG_NAME, "p.info-title.text--card-head"))
        ).text 

    except:
        table = WebDriverWait(driver, 20).until(
            EC.presence_of_element_located((By.TAG_NAME, "h4.title.text--card-link"))
        ).text
        names = 'Мы ничего не нашли'
    
    return table, names




    driver = webdriver.Chrome(executable_path='D:\chromedriver.exe')
    driver.get('https:///about/security/reestr-brokerov-i-agentov')
    t = import_dates(i, q)
    inn.append(q)
    datas.append(t[0])
    namess.append(t[1])
    driver.quit()


df = pd.DataFrame(inn)
df['ВИДЫ'] = datas
df['ФИО'] = namess


The problem is this... After some iteration, the widget window pops up and I can't close it. In the code above, I noted how I tried to fight with the widget, but it did not work out.

It gives the following error...
Message: element click intercepted: Element <button type="submit" class="form__button-submit btn--basic" data-v-1b4d1132="" data-v-7b3c43ec="">...</button> is not clickable at point (467, 476). Other element would receive the click: <iframe class="flocktory-widget" id="fl-539950" title="Flocktory widget" frameborder="0" scrolling="no" style="width: 100%; height: 100%;"></iframe>
  (Session info: chrome=94.0.4606.81)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-10-15
@san_m_m

The sequence of actions:
1) Before clicking, check for the presence of an iframe widget
2) If there is, switch to an iframe with a widget
3) Click the close button in it
4) Restore the iframe context
5) Continue working
Switch to iframe :

# Xpath надо написать самому
iframe = driver.find_element_by_xpath("//iframe")
driver.switch_to.frame(iframe)

Restore iframe context
driver.switch_to.default_content()
Or you can use requests
import requests

params = {
    'name': 'Иванов Иван Иванович',
    'numberOrInn': '1111111111',
}

response = requests.get('https://www.rgs.ru/api/agents/checkAgent', params=params)

# {"Status":"NotFound","ErrorCorrelationIds":[],"ErrorCode":null}
print(response.text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question