Search code examples
python-3.xsiemenss7-1200

Siemens S7-1200: Cannot download datalog


I have problem downloading my datalog. Already make a coding using python to automatically download the datalog everyday. And the coding works on three sites. But, on the fourth site, using the same code, I got an ERROR 404 not found. But, the files can be download manually, by clicking it.

Already try searching for the problem in the siemens forum but to no avail.

So, if anyone had experience with this problem and have solution please share with me.

here is my coding;

    import subprocess
    import datetime
    import wget
    from datetime import date, timedelta

    yesterday = date.today() - timedelta(1)
    x = yesterday.strftime("%y%m%d")
    print ("Downloading F_" + x + ".csv")

    datetime_object = datetime.datetime.now()

    url = 'http://{PLC_IP}/FileBrowser/Download?Path=/DataLogs/F_' + x + '.csv'

    filename = wget.download(url)

    filename

Thank you.


Solution

  • I don't really know what is blocking my coding from downloading the datalog in the web server. But, after trying different coding which I found here I got it working.

    Hope this help.

    EDIT/UPDATE 1:

    OPs issue is related to S7-1214 firmware V04.02.01.
    Solution below works from firmware version 4.2.
    Solution provided by OP Sebastian Geier.

    :: Login to the webserver. User name: admin, password: admin, IP of the PLC: 192.168.0.1. Store the cookies after Login in "cookies.txt" and keep the session active for the copy procedure

    wget.exe --no-check-certificate --post-data="Redirection&Login=admin&Password=admin&submit=Anmelden" --save-cookies=cookies.txt --referer=http://YOUR_IP/Portal/Portal.mwsl?PriNav=Start --keep-session-cookies http://YOUR_IP/FormLogin

    :: Load the cookies again and switch to the "Filebrowser" of the webserver. There, the file "MyDataLog.csv" will be copied to the Desktop, called "info.csv" :: Load the file wget.exe --no-check-certificate --load-cookies=cookies.txt --referer=http://YOUR_IP/Portal/Portal.mwsl?PriNav=FileBrowser?Path=/DataLogs http://YOUR_IP/FileBrowser/Download?Path=/DataLogs/Counter_Export.csv--output-document=store/DataLog_LogOn_S7-1200.csv

    Note: also add the instruction: path=\Datalogs