Scrape all the values I care about.
This commit is contained in:
parent
1ec7473793
commit
b23afaeac8
39
main.py
39
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.
|
url = 'http://192.168.1.1'
|
||||||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
|
||||||
|
|
||||||
|
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):
|
if snr_element:
|
||||||
# Use a breakpoint in the code line below to debug your script.
|
snr_value = snr_element.text.strip().split()[0] # Extracting the numerical part
|
||||||
print(f'Hi, {name}') # Press Ctrl+8 to toggle the breakpoint.
|
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 rsrp_element:
|
||||||
if __name__ == '__main__':
|
rsrp_value = rsrp_element.text.strip()
|
||||||
print_hi('PyCharm')
|
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.")
|
||||||
Loading…
x
Reference in New Issue
Block a user