Python - Browser Automation - MechanicalSoup/ BeautifulSoup

2.5k Views Asked by At

I am attempting to automate a button push that prompts javascript on my own website(godaddy server). I am running a .py from my MAC OS Terminal.

I have found beautiful soup and mechancial soup but only found documentation for parsing text or prefilling forms. I have attempted mechanical soup code absent any 'form' mention, and merely trying to click a button based on a css selector.

I have played around with this code for a few hours and am not convinced what I want to accomplish is possible. Can anyone confirm this is possible with either of these modules? If not, what is a better tool?

I have just been using the example provided here: https://mechanicalsoup.readthedocs.io/en/stable/tutorial.html#first-contact-step-by-step

my code in a function:

def updatePrices()
    br = mechanicalsoup.StatefulBrowser()
    br.open("http://example.com")
    br.get_current_page().find('button', id='exporter_decisionStream')
    br.submit_selected()
updatePrices()

Any guidance is appreciated. Thanks.

0

There are 0 best solutions below