Scrape all the values I care about.

This commit is contained in:
john 2024-05-08 21:43:13 -07:00
parent 1ec7473793
commit b23afaeac8

39
main.py
View File

@ -1,16 +1,35 @@
# This is a sample Python script.
import requests
from bs4 import BeautifulSoup
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
url = 'http://192.168.1.1'
response = requests.get(url, verify=False)
soup = BeautifulSoup(response.text, 'html.parser')
snr_element = soup.find('div', id='snr')
pci_element = soup.find('div', id='pci')
rsrp_element = soup.find('div', id='internetStatusRSRP')
rsrq_element = soup.find('div', id='internetStatusRSRQ')
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+8 to toggle the breakpoint.
if snr_element:
snr_value = snr_element.text.strip().split()[0] # Extracting the numerical part
print(f"SNR value: {snr_value}")
else:
print("SNR value not found on the page.")
if pci_element:
pci_value = pci_element.text.strip()
print(f"PCI value: {pci_value}")
else:
print("PCI value not found on the page.")
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
if rsrp_element:
rsrp_value = rsrp_element.text.strip()
print(f"RSRP value: {rsrp_value}")
else:
print("RSRP value not found on the page.")
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
if rsrq_element:
rsrq_value = rsrq_element.text.strip()
print(f"RSRQ value: {rsrq_value}")
else:
print("RSRQ value not found on the page.")