Я пытаюсь пройтись по всем параметрам, просматривая сайт. Проблема в том, что параметры кажутся скрытыми в приложении javascript, и я не могу найти элемент, по которому нужно щелкнуть, чтобы получить список параметров.
Я попытался запустить приложение javascript и выбрать нужный элемент, но, похоже, он бесполезен.
from selenium.webdriver.support.ui import Select
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from bs4 import BeautifulSoup
import time
import json
import os
url = 'https://www.mfsa.com.mt/financial-services-register/'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(1)
select = Select(driver.find_element_by_id("select1"))
select2 = Select(driver.find_element_by_id("select2"))
soup = BeautifulSoup(driver.page_source, 'html.parser')
test_soup = soup.find(id="select2-drop-mask")
driver.execute_script("document.getElementById('select2-drop-mask').style.display='block';")
test1 = driver.find_element_by_id("select2-drop-mask")
test1 = driver.find_element_by_class_name('select2-drop-mask')
test1 = driver.find_element_by_class_name('select2-search')
print(test1.get_attribute('HTML'))
test1.click()
test1 = driver.find_elements_by_id('select2-results-1')
for li in test1:
print(li.get_attribute('HTML'))
test1.click()
test1 = driver.find_element_by_css_selector("a[href*='0']")
print(test1.get_attribute('innerHTML'))
test1 = driver.find_element_by_class_name('select2-hidden-accessible')
print(test1.get_attribute('innerHTML'))
test1.click()
options = [x for x in test1.find_elements_by_tag_name("a")]
for option in options:
print(option.get_attribute('innerHTML'))
test1 = driver.find_element_by_id('select2-drop')
test1.click()
test1 = driver.find_element_by_class_name('select2-arrow')
print(test1.get_attribute('innerHTML'))
test1.click()
test1 = driver.find_element_by_id('select2-chosen-1')
print(test1)
test1.click()
test1 = driver.find_element_by_id('select2-drop-mask')
print(test1)
test1.click()
test1 = driver.find_element_by_id('select2-results-2')
print(test1)
test1.click()
test1 = driver.find_element_by_id('s2id_autogen2_search')
print(test1)
test1.click()
test1 = driver.find_element_by_id('s2id_select1')
print(test1)
test1.click()
test1 = driver.find_element_by_class_name('select2-search')
print(test1)
test1.click()
Результат, который я ожидал, это список всех опций, поэтому я могу просмотреть их и получить список зарегистрированных компаний. Спасибо!