From b23afaeac867d71d7eeeb216f6e0e87e3bac4e17 Mon Sep 17 00:00:00 2001 From: john Date: Wed, 8 May 2024 21:43:13 -0700 Subject: [PATCH] Scrape all the values I care about. --- main.py | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 68aa93d..5214c96 100644 --- a/main.py +++ b/main.py @@ -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.") \ No newline at end of file