"There is only a GUI via a web browser." When I was looking for ways to automate the construction of MW, I did not find it immediately when I searched for it, so I made a note.
$ pip install selenium
$ brew install chromedriver
sample.py
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import, unicode_literals
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
options = webdriver.ChromeOptions()
options.add_argument('--incognito') # secret mode
options.add_experimental_option('prefs', {'intl.accept_languages': 'en_US'}) # locale=en_US
# use local driver
driver = webdriver.Chrome(chrome_options=options)
## use remote driver
#driver = webdriver.Remote(
# command_executor='http://127.0.0.1:4444/wd/hub',
# desired_capabilities=options.to_capabilities())
driver.get("https://www.debian.org/")
assert "Debian" in driver.title
elem = driver.find_element_by_name("P")
elem.clear()
elem.send_keys("debi_fujin")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
When executed, it looks like this.
$ python sample.py
As a point of addiction
It is around.
Reference: [Selenium] How to set Accept \ -Language header with python \ + ChromeDriver -miyajan blog
Recommended Posts