Для описанной цели я еще не закончил писать код еще полностью, но довольно рано я столкнулся с проблемой, которую пытаюсь исправить уже несколько дней. В приведенном ниже коде кнопка для нажатия в меню дезагрегации не будет работать (либо выдает ошибку, либо просто игнорируется). Раскрывающийся список вопросов работает, но что-то не так с частью дезагрегации (disagg_buttons). См. ниже:
Код: Выделить всё
URL = "https://secure.panoramaed.com/ride/understand/1302972/survey_results/27746568#/questions"
URL2 = "https://secure.panoramaed.com/ride/understand?auth_token=geZrUH8yRr8_Ln_C9LH3"
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 bs4 import BeautifulSoup
import os
driver=webdriver.Firefox()
driver.get(URL2)
driver.get(URL)
html_text = driver.page_source
# Finds each question in the webpage based on the class "expandable-row". This will identify all of the questions on the page.
questions_buttons = driver.find_elements(By.CLASS_NAME, "expandable-row")
# Opens each drop down menu so that we can see all of the disaggregations of each question.
for question_button in questions_buttons:
question_button.click()
# Finds each disaggregation breakdown button by the class "highcharts-a11y-proxy-button.highcharts-no-tooltip".
disagg_buttons = driver.find_elements(By.CSS_SELECTOR, 'button.highcharts-a11y-proxy-button highcharts-no-tooltip')
for disagg_button in disagg_buttons:
disagg_button.click()
# When the disaggregation button is clicked, this will select the first item in the list which is the "View Data Table" option.
view_datatable_button = driver.find_element(By.CLASS_NAME, "li")
view_datatable_button.click()
rendered_html = driver.find_elements(By.CLASS_NAME, "ng-scope")
for e in rendered_html:
pass
# soup=BeautifulSoup(html_text, "html.parser")
# soup_pretty = soup.prettify()
# print(soup_pretty)
# file = open("output.txt", "a")
# file.write(html_text)
# file.close()
Подробнее здесь: https://stackoverflow.com/questions/787 ... my-webpage