Search code examples
pythonweb-scrapingbeautifulsouppython-requestsmechanize

Python click button on web page without selenium


So there is a button on a webpage that downloads a csv file after clicking it. In the past I have used selenium to do this, but given the current application of this script being ran on databricks I'd rather not use a web driver. However, when I inspect the button I see no URL or a JS function call. Here is what the html looks like:

<button id="exportReport" class="button">
                    Export Report                   
                </button> == $0

I would link the webpage, but it requires a log in. Is there any way I can simulate clicking this button via requests, mechanize, or beautiful soup?


Solution

  • Copying my comment to the answer:

    Use the Chrome dev tools (F12) > Network tab. Click the button on the web page to see where the CSV comes from:

    Chrome Tools Network Tab