Reputation: 21
I am trying download the event and WLAN logs from my AVM FritzBox 7350 router (OS 7.57) in JSON format using a Python 3 script. Whilst it works well on my ArchLinux machine, I only get a HTML file on my Raspberry Pi server (Raspbian Bullseye) for no obvious reason. Both machines run Python 3.12.4.
For generating a Session-ID (SID) and logging in I rely on the code in the AVM technical note here.
Generating the SID and logging in work perfectly well. Then, I download a logfile, e.g. 'page=wSet' or 'page=log', using a python subprocess which calls a bash 'wget' command sending POST data as seen in the following function:
def download_log(sid: str) -> str:
cmd = 'wget -q -O - --post-data="sid='+sid+'&lang=de&page=wSet&no_sidrenew=" http://fritz.box/data.lua?version=2'
# .........................................................................V use system's UTF-8 encoding)
return str(subprocess.check_output(cmd, shell=True, executable="/bin/bash",text=True))
I write the returned string to my 'logfile':
with open('./logfile','w') as logfile:
logfile.write(download_log(sid))
This, again, works perfectly well on my ArchLinux-System and results in a file formatted as JSON which I expected after reading the tutorial here / english Google translation. It is easily parsable with 'jq'.
However, when I run the VERY SAME script on my Raspberry Pi server (Raspbian 11 (Bullseye)), all I get is a HTML file of a page asking me, if I want to enter the FritzBox interface [see attached image, unfortunately all german]...
HTML file returned from 'wget' on Raspberry Pi
On both systems Python 3.12.4 is successfully installed. Both are connected to the FritzBox via wifi. I do not see what could cause the different behaviour of the 'wget' routine on both machines.
Does anyone have a clue?
Best regards,
.tinkertoadie
Upvotes: 0
Views: 50
Reputation: 21
'wget' on the Raspberry Pi was outdated.
I do not know any details about the different behaviour, but something obviously changed from version 1.21 (which was installed on the Raspbian system) to 1.24 (installed on the ArchLinux system).
Simply get and build the most recent 'wget' version that can be found here.
The command
wget -q -O - --post-data="sid=XXXXXXXXXXXX&lang=de&page=wSet&no_sidrenew=" http://fritz.box/data.lua?version=2'
will then return the WLAN activity log in JSON format from your FritzBox. Make sure, that you replace XXXXXXXXXXXX with the Session-ID you generated according to the technical note by AVM.
Upvotes: 1