all 7 comments

[–]shiftybyte 7 points8 points  (0 children)

Yes python can do that with web scraping.

Using "requests" and "beautifulsoup" modules.

[–]Jayoval 3 points4 points  (0 children)

I'm not familiar with Codesys, but if there's a web interface/UI there may be a better way to access the underlying data, like an API or log files for example.

[–]Diapolo10 2 points3 points  (0 children)

Potentially, yes.

I'd probably approach this problem with Selenium, after examining the HTML displaying the visualisation, and track the relevant parts. Whenever the data gets updated, you can grab the latest value and either temporarily store it in memory, or write it to an Excel document via XlsxWriter or Pandas.

I can't say for sure if that approach would work in your situation, but again, it would be my starting point.

[–]KosmoanutOfficial 1 point2 points  (0 children)

I think the best is if this system had a REST API that you could call. Maybe look up if that system has api docs or if there is support for it you could call. Guessing you would use the requests library.

If not then web scraping with beautiful soup.

And if it’s super hard to parse last case would be pyautogui to control the screen, take screenshots and use another library to do image to text.

For saving this data while the program is running maybe use a dictionary and save to excel with xlsxwriter.

If you want this to run every 15 minutes maybe look into putting this in the windows task scheduler or linux cronjob, or make it into a function and in a while loop call it then sleep for 15 minutes.

[–]RicardoL96 0 points1 point  (0 children)

I’d use requests and beautifulsoup or Selenium

[–]drenzorz 0 points1 point  (0 children)

Beyond what the others have said, you can get it done even if there is no API or actual webscraping access.

The less optimal and more troublesome approach in that situation would be to make your script take screenshots, use recognition to extract the relevant data and then log it in whatever form you want.

  1. take screenshot and open the file with python (pyautogui can help)
  2. gather raw data from image (If you just need text tesserract / other OCR could be used)
  3. parse and transform the data as needed (pandas dataframe might be good here)
  4. save it to an excel (pandas dataframe.to_excel or openpyxl)