A library for managing home routers (networking equipment).
roscraco (short for ROuter SCRAping and COntrol) is a library for managing networking devices (routers).
The targeted (and currently supported) devices are home routers.
Settings are fetched and pushed from/to devices by using their standard web-management interface (HTTP).
The type of device being managed is abstracted away and is only important initially (when the controller object is created). From the developer’s standpoint, settings are then managed the same way regardless of the device’s type.
roscraco is available on PyPI and can be installed using pip or easy_install:
pip install roscraco
roscraco aims to be compatible with python2 and python3. If you notice any compatibility problems, please let us know.
The library supports the following devices:
Some of the (usually more advanced) options of a given settings object cannot be controlled. For most of these options a “sane” value (usually default) is picked and will potentially overwrite any custom values that are currently set.
Creating a controller instance:
import roscraco controller = roscraco.create_controller( roscraco.ROUTER_TP_LINK, 'WR340G', 'localhost', 8080, 'username', 'password' )
Print a lot of information about the device:
Change some Wireless settings:
# Fetch the current wireless settings settings = controller.get_wireless_settings() # Switch to the next transmission channel settings.set_channel(settings.channel + 1) # Disable password authentication settings.set_security_type(settings.SECURITY_TYPE_NONE) # Change the SSID (network name) settings.set_ssid('NewNetworkName') # Send the new wireless settings to the router controller.push_wireless_settings(settings)
Be nice and log out of the device properly (you can also use contextlib.closing):