基本環境
1、python
https://www.python.org/downloads/windows/
2、splinter
https://pypi.org/project/splinter/
3、firefox driver(geckodriver)
https://github.com/mozilla/geckodriver/releases
4、chrome driver
http://chromedriver.storage.googleapis.com/index.html
示例
from splinter import Browser
with Browser() as browser:
url = "搜索引擎"
browser.visit(url)
browser.fill('q', 'splinter - python acceptance testing for web applications')
button = browser.find_by_name('btnG')
button.click()
if browser.is_text_present('splinter.readthedocs.org'):
print "Yes, the official website was found!"
else:
print "No, it wasn't found... We need to improve our SEO techniques"