Last active
May 28, 2021 17:45
-
-
Save ajinux/63ed498463b5a9ebe788fc546af4e56d to your computer and use it in GitHub Desktop.
Simple python script to fetch details from JioFi (dongle) device
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
#!/usr/bin/python3 | |
from bs4 import BeautifulSoup | |
import requests | |
URL = "http://192.168.225.1/cgi-bin/en-jio/mStatus.html" | |
page = requests.get(URL).text | |
soup = BeautifulSoup(page, 'html.parser') | |
important_metrics = ["rsrp", "battery_capacity", "battery_status", "downloaded_data", "uploaded_data"] | |
scrap_data = { | |
"connection_time" : "lDashCurConnValue", | |
"operating_band" : "pDashEngineerInform_bandValue", | |
"bandwidth" : "pDashEngineerInform_bandwidthValue", | |
"earfcn" : "pDashEngineerInform_earfcnValue", | |
"physical_cell_id" : "pDashEngineerInform_phycellValue", | |
"plmn" : "pDashAutoApn_plmnValue", | |
"apn" : "pDashAutoApn_LteApnValue", | |
"global_cell_id" : "pDashEngineerInform_globalCellValue", | |
"ecgi" : "pDashEngineerInform_ecgiValue", | |
"rsrp" : "pDashEngineerInform_rsrpValue", | |
"rsrq" : "pDashEngineerInform_rsrqValue", | |
"sinr" : "pDashEngineerInform_sinrValue", | |
"ipv4" : "LIPV4AddValue", | |
"subnet" : "LIPV4NetmaskValue", | |
"ipv4_default_gateway" : "LIPV4GatewayValue", | |
"ipv4_dns_server" : "LDNSIPV4Value", | |
"ipv6" : "LIPV6AddValue", | |
"ipv6_prefix_length" : "LIPV6PrefixLength", | |
"ipv6_default_gateway" : "LIPV6GatewayValue", | |
"ipv6_dns_server" : "LDNSIPV6Value", | |
"ssid" : "lWirelessNwValue", | |
"lan_operating_mode" : "lLanOperMode", | |
"subnet_mask" : "lRouterMask", | |
"gateway_ip" : "lRouterIP", | |
"mac_address" : "lRouterMAC", | |
"automatic_channel_selection" : "lAutoChannelStatus", | |
"wifi_channel" : "lChannelNumber", | |
"wifi_channel_bandwidth" : "lBandwid", | |
"wireless_security" : "lSecurityModeValue", | |
"no_of_devices" : "lConnDeviceValue", | |
"uploaded_data" : "lsentPackets", | |
"downloaded_data" : "lRecPackets", | |
"connection_url" : "tdns_addr", | |
"device_time" : "urrenttime", | |
"odm" : "lODM", | |
"product_id" : "lProductID", | |
"oui" : "lOUI", | |
"serial_number" : "lSerialNum", | |
"imei" : "pDashRouterImeiValue", | |
"imsi" : "lIMSI", | |
"msisdn" : "lMSISDN", | |
"iccid" : "lICCID", | |
"battery_status" : "lDashChargeStatus", | |
"battery_capacity" : "lDashBatteryQuantity", | |
"primary_mac_id" : "lPrimaryMacIdValue", | |
"host_name" : "lPrimaryHostNameValue", | |
"frequency_bands_supported" : "lPrimaryHostNameValue", | |
"firmware_version" : "lSoftVersion", | |
"firmware_created_date" : "lCurrentSoftwareDateValue", | |
"hardware_version" : "lHardVersion", | |
"refresh_rate" : "lpeformanceMonitorPeriod", | |
"max_cpu_usage" : "lcpuMaxUsage", | |
"min_cpu_usage" : "lcpuMinUsage", | |
"max_memory_usage" : "lmaxMemoryUsage", | |
"min_memory_usage" : "lminMemoryUsage", | |
"ul_current_data_rate" : "lulCurrentDataRate", | |
"ul_max_data_rate" : "lulMaxDataRate", | |
"ul_min_data_rate" : "lulMinDataRate", | |
"dl_current_data_rate" : "ldlCurrentDataRate", | |
"dl_max_data_rate" : "ldlMaxDataRate", | |
"dl_min_data_rate" : "ldlMinDataRate" | |
} | |
for metric, id in scrap_data.items(): | |
if metric not in important_metrics: | |
continue | |
print("{0} : ".format(metric.lower()), end="") | |
all_elements = soup.findAll(id=id) | |
if len(all_elements) == 1: | |
print(all_elements[0].text) | |
elif len(all_elements) > 1: | |
print("Multiple value found for id - {0}".format(id)) | |
elif len(all_elements) == 0: | |
print("No value found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment