Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'group' #8

Open
nonomega opened this issue Jul 8, 2022 · 4 comments
Open

AttributeError: 'NoneType' object has no attribute 'group' #8

nonomega opened this issue Jul 8, 2022 · 4 comments

Comments

@nonomega
Copy link

nonomega commented Jul 8, 2022

Hi,

First : thanks for your code. I hope it will be usefull for monitoring my entire network.

Second :
I've got this issue : AttributeError: 'NoneType' object has no attribute 'group'

Here the trace in Debug Mode.

I already checked for a similar issue but still not working.

Could you please have a look and support me fixing this issue ?

I'm running on a pi4 with Python v3.9 / bs4 v4.11.1

Thanks in advance

nONo


python3 essstat.py 192.168.1.247 -d -u "admin" -p "________________"
admin
wap_zbpllstr4d_s
http://192.168.1.247
BeautifulSoup4 version: 4.11.1
<Response [200]>
True
[<script src="common.js" type="text/javascript"></script>,

<script src="ui.js" type="text/javascript"></script>, <script src="help.js" type="text/javascript"></script>, <script type="text/javavar link_info = new Array("Link Down", "Auto", "10Half", "10Full", "100H</script>]nctiondocument.location.href="PortStatisticsRpm.htm"; <script type="text/javascript"> var tmp_info = "1 5 157367329 0 64271501 0 1 0 0 0 0 0 1 5 129070523 0 18987688 0 1 0 0 0 0 0 1 5 199346829 0 108833727 7 1 0 0 0 0 0 1 5 3705591447 0 2561246977 0 1 0 9720430 0 865623 0 1 5 200550513 0 98656584 0 1 6 2236506455 0 3581761041 0 1 6 318911311 0 229635537 37 1 6 2283593391 0 2184834122 0 1 6 1437775793 0 1104743954 858875 1 5 133851404 0 24838118 0 1 0 0 0 0 0 1 0 0 0 0 0 "; var all_info = tmp_info.split(" "); var port_middle_num = 16; for (index = 0; index < port_middle_num; index++) { port_id = index + 1; port = "Port " + port_id; state = state_info[Number(all_info[index * 6])]; link_status = link_info[Number(all_info[index * 6 + 1])]; tx_good = Number(all_info[index * 6 + 2]); tx_bad = Number(all_info[index * 6 + 3]); rx_good = Number(all_info[index * 6 + 4]); rx_bad = Number(all_info[index * 6 + 5]); document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write(""); if (max_port_num > port_middle_num) { var tmp_info2 = ""; var all_info2 = tmp_info2.split(" "); for (index = port_middle_num; index < max_port_num; index++) { port_id = index + 1; port = "Port " + port_id; state = state_info[Number(all_info2[(index - port_middle_num) * 6])]; link_status = link_info[Number(all_info2[(index - port_middle_num) * 6 + 1])]; tx_good = Number(all_info2[(index - port_middle_num) * 6 + 2]); tx_bad = Number(all_info2[(index - port_middle_num) * 6 + 3]); rx_good = Number(all_info2[(index - port_middle_num) * 6 + 4]); rx_bad = Number(all_info2[(index - port_middle_num) * 6 + 5]); document.write(""); document.write("" + document.write(""); document.write("" + document.write(""); document.write("" + link_status); document.write(""); document.write("" + tx_good); document.write(""); document.write("" + document.write(""); document.write("" + rx_good); document.write(""); document.write("" + document.write(""); document.write(""); </script> }

Traceback (most recent call last):
File "/home/pi/essstat/essstat.py", line 169, in
print(pattern.search(str(soup.head.find_all("script"))).group(0))
AttributeError: 'NoneType' object has no attribute 'group'

@psmode
Copy link
Owner

psmode commented Jul 8, 2022 via email

@nonomega
Copy link
Author

nonomega commented Jul 8, 2022

Hello Peter

I'm using bs4 v4.11.1
I tried others version (previous ones) but still the same issue.

Thanks in advance for your help

nONo

@Napsty
Copy link

Napsty commented Nov 30, 2023

Getting the same error AttributeError: 'NoneType' object has no attribute 'group' when running the script on a Debian 11 with bs4 4.9.3. Switch is a TL-SG1024DE 6.0 with firmware 1.0.0 Build 20220825 Rel.69073.

Debug:

ckadm@icinga2:~/essstat$ ./essstat.py -p secret -u admin myswitch -d 
admin
secret
http://myswitch
BeautifulSoup4 version: 4.9.3
<Response [200]>
False
<script>
var logonInfo = new Array(
0,
0,0);
var g_Lan = 1;
var g_year=2022;
</script>
Traceback (most recent call last):
  File "/home/ckadm/essstat/./essstat.py", line 173, in <module>
    print(pattern.search(str(soup.script)).group(0))
AttributeError: 'NoneType' object has no attribute 'group'

@Napsty
Copy link

Napsty commented Nov 30, 2023

After upgrading the switch firmware to TL-SG1024DE(UN)_V6_1.0.0 Build 20230220, your script works :)

ckadm@icinga2:~/essstat$ ./essstat.py -p secret -u admin myswitch
2023-11-30 15:19:13
max_port_num=24
1;Enabled;Link Down;0,0,0,0
2;Enabled;1000M Full;454,0,46,0
3;Enabled;1000M Full;4423,0,3514,0
4;Enabled;Link Down;0,0,0,0
5;Enabled;Link Down;0,0,0,0
6;Enabled;1000M Full;919,0,335,0
7;Enabled;Link Down;0,0,0,0
8;Enabled;Link Down;0,0,0,0
9;Enabled;Link Down;0,0,0,0
10;Enabled;100M Full;182,0,347,0
11;Enabled;Link Down;0,0,0,0
12;Enabled;Link Down;0,0,0,0
13;Enabled;Link Down;0,0,0,0
14;Enabled;Link Down;0,0,0,0
15;Enabled;Link Down;0,0,0,0
16;Enabled;Link Down;0,0,0,0
17;Enabled;Link Down;0,0,0,0
18;Enabled;Link Down;0,0,0,0
19;Enabled;Link Down;0,0,0,0
20;Enabled;Link Down;0,0,0,0
21;Enabled;1000M Full;114666,0,56389,0
22;Enabled;Link Down;0,0,0,0
23;Enabled;1000M Full;44962,0,94301,0
24;Enabled;1000M Full;15619,0,24160,0

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants