Closed jan-lukes closed 3 years ago
Just for grins, could you rerun specifying python3 instead of python in your command line?
If still failing, please add the -d switch to the command line and send me the output please (after washing out the password)
Hi, there it is.
$ python3 essstat.py 192.168.0.4 -d -u "admin" -p "password"
admin
password
http://192.168.0.4
<Response [200]>
<script>
var max_port_num = 8;
var port_middle_num = 16;
var all_info = {
state:[1,1,1,1,1,1,1,1,0,0],
link_status:[6,6,6,6,6,5,3,6,0,0],
pkts:[284323486,0,136512246,0,1399381846,0,740239959,0,1307151387,0,2192699492,0,342486595,0,165520469,0,148530212,0,153646289,0,67519215,0,1697217,0,93655084,0,16167888,0,396838052,0,205397704,0,0,0]
};
var tip = "";
</script>
Traceback (most recent call last):
File "/home/lucky/build/essstat/essstat.py", line 149, in <module>
print(pattern.search(soup.script.text).group(0))
AttributeError: 'NoneType' object has no attribute 'group'
Thank You!
The problem is with a breaking change that beautifulsoup introduced sometime after v4.8.2.
My systems where I coded this and it is running today use beautifulsoup4-4.8.2. I tried with beautifulsoup4-4.9.3 and got the behavior you did, reverted to beautifulsoup4-4.8.2 and it worked fine.
As a workaround, you could go back to the older version of beautifulsoup while I track down what broke with the newer library and implement a fix:
pip uninstall beautifulsoup4 pip install beautifulsoup4==4.8.2
Yes.
Works! Thank You for your workaround. You make me really happy day. :)
I will patiently wait for your next releases....
Good Job!
The code problem centers on the references to soup.script.text, which are no longer valid with the newer version of BeautifulSoup. The fix appears to be to change these to soup.script.string, which has the added benefit of being backwards compatible, at least to beautifulsoup4-4.8.2.
I am going to do some more testing before publishing the code fix, but I should have this out rather soon. I'd also like to look into how this change came about. It is possible that I was using a coding convention that had been deprecated earlier and finally fell off with the update to BeautifulSoup. If there is something else about to break, I'd like to get ahead of that.
This issue has been addressed by the change in essstat.py in v4.0.1
Python 3.9.1 python-beautifulsoup4 4.9.3-3 tp-link TL-SG108E
Input:
# python essstat.py 192.168.10.4 -u"admin" -p"xxxxxxxx"
Output: