I want to access data from an html table from the section "ERGEBNIS" with python 3.7.
The problem is, that the results for each combination of the drop down values are only shown after clicking on submit. This does however not change the url, so that I have no idea how I can access the results table after updating the input values of the drop downs.
Here is what I've done so far:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time
browser.get('https://daten.ktbl.de/feldarbeit/entry.html')
#Fix values of the drop down fields:
fertilizer = Select(browser.find_element_by_name("hgId"))
fertilizer.select_by_value("2")
fertilizer = Select(browser.find_element_by_name("gId"))
fertilizer.select_by_value("193")
fertilizer = Select(browser.find_element_by_name("avId"))
fertilizer.select_by_value("383")
fertilizer = Select(browser.find_element_by_name("hofID"))
fertilizer.select_by_value("2")
fertilizer = Select(browser.find_element_by_name("flaecheID"))
fertilizer.select_by_value("5")
fertilizer= Select(browser.find_element_by_name("mengeID"))
fertilizer.select_by_value("60")
# Submit changes to show the results of this particular combination of values
button = browser.find_element_by_xpath("//*[@type='submit']")
button.click()
Submitting the changes does, however, not change the url, so that I don't know how I can access the results (here "ERGEBINS") table.
Otherwise my approach would have been to use pd.read_html somehow like this:
...
url = browser.current_url
time.sleep(1)
df_list = pd.read_html(url, match = "Dieselbedarf")
But since the url isn't unique for each result, this doesn't make sense. Same issue would be with BeautifulSoup, or at least I don't understand how I can do it without a unique url..
Any ideas how I can access the html table otherwise?
EDIT: The answer of @bink1time could solve my problem how to access the table without the url, but via the raw HTML string:
html_source = browser.page_source
df_list = pd.read_html(html_source, match = "Dieselbedarf")