Created
March 18, 2019 02:25
-
-
Save ThrowsException/7a50ddcca586da13abb653cc0002ef29 to your computer and use it in GitHub Desktop.
PBX device state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
# create a password manager | |
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm() | |
# Add the username and password. | |
# If we knew the realm, we could use it instead of None. | |
top_level_url = "http://192.168.1.218:8088/ari/" | |
password_mgr.add_password(None, top_level_url, "testuser", "password") | |
handler = urllib.request.HTTPBasicAuthHandler(password_mgr) | |
# create "opener" (OpenerDirector instance) | |
opener = urllib.request.build_opener(handler) | |
# use the opener to fetch a URL | |
opener.open("http://192.168.1.218") | |
# Install the opener. | |
# Now all calls to urllib.request.urlopen use our opener. | |
urllib.request.install_opener(opener) | |
with urllib.request.urlopen('http://192.168.1.218:8088/ari/deviceStates') as response: | |
html = response.read() | |
print(html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment