I want to find downloadable content in a webpage but I don't know what the webpage looks like. Right now, I am looking at all links
links = driver.find_elements(By.XPATH, "//a[@href]")
and buttons
buttons = driver.find_elements(By.TAG_NAME, "button")
For each link (which has an href attribute as seen in the XPATH specification), I check whether or not it points to a page with some form of machine readable file I am looking for (either .csv or .json); if the link does not have one of these extensions as a suffix, I assume it does not reference a machine readable file.
As for the buttons, I know of no way to check what they may contain other than naively clicking on them (button.click()). While this is clearly dangerous, especially because this function will be applied on thousands of websites, I don't know how else to do it.
Is there any other way I could check for downloadable content? Additionally, are there any other page elements I should be looking for, besides links and buttons, and are there any more efficient methods of doing what I want?
Any help is greatly appreciated. Thanks!