Controlling a browser using Python, on a Mac

后端 未结 10 2202
小鲜肉
小鲜肉 2021-02-02 02:57

I\'m looking for a way to programatically control a browser on a Mac (i.e. Firefox or Safari or Chrome/-ium or Opera, but not IE) using Python.

The actions I need includ

10条回答
  •  盖世英雄少女心
    2021-02-02 03:17

    Maybe overpowered, but check out Marionette to control Firefox. There is a tutorial at readthedocs:

    You first start a Marionette-enabled firefox instance:

    firefox -marionette
    

    Then you create a client:

    client = Marionette('localhost', port=2828)
    client.start_session()
    

    Navigation f.ex. is done via

    url = 'http://mozilla.org'
    client.navigate(url)
    client.go_back()
    client.go_forward()
    assert client.get_url() == url
    

提交回复
热议问题