Kaasplakje Posted December 24, 2019 Posted December 24, 2019 Hi there I am new to autoIT and am trying to create a script which filters HTML sourcecode on a messages and returns a pop up with the latest one. Here is a example of the sourcecode: "MessageID":19652,"Timestamp":"2019-12-24T07:46:51.713","Tag":"","Text":"Text here","Type":"Chat","Votes":1,"Enabled":true,"User":{"Name":"Kaasplake","Division":"X"},"Division":"X"},{ I filter the sourcecode with : $Source = BinaryToString(InetRead('https://ccsd.intern.rabobank.nl/Shoutbox/', 1)) ;Select the chunks from the website source code $FirstChunks = _StringBetween($Source, '{"MessageID":', '"},' ) ;Takes the log from the source code For $a In $FirstChunks ConsoleWrite($a & @CRLF) Next Which returns a array filled with every chunk of the source code. But now I want to filter these chunks further into lets say: $name , $message, $date but I am not sure how to do this in AutoIT could you guys push me into the right direction. Thanks a lot from a starting autoIT user. - Kaasplakje
Developers Jos Posted December 24, 2019 Developers Posted December 24, 2019 @Kaasplakje, That data looks a lot like a part of a JSON encoded dataset. Maybe it is easier to simply use one of the json UDF's available in the form to read the data. We would require a proper set of outputdata to assist though. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Nine Posted December 24, 2019 Posted December 24, 2019 (edited) One other solution is to use SRE to extract the 3 fields into an array like this : #include <Array.au3> Const $sTxt = '"MessageID":19652,"Timestamp":"2019-12-24T07:46:51.713","Tag":"","Text":"Text here","Type":"Chat","Votes":1,"Enabled":true,"User":{"Name":"Kaasplake","Division":"X"},"Division":"X"},{' Local $aArray = StringRegExp ($sTxt, '"Timestamp":"(.+?)".+"Text":"(.+?)".+"Name":"(.+?)"', $STR_REGEXPARRAYMATCH) _ArrayDisplay ($aArray) I suppose message = Text ? Btw : you could do all in SRE without using _StringBetween... Edited December 24, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Kaasplakje Posted December 24, 2019 Author Posted December 24, 2019 Hi Jos, Thanks for the reply. I only have access to the source code via > chrome inspect and am not sure where I can find the proper JSON encoded dataset to show this to you. I looked into the .js file and found this but as I said I'm not sure if this is what you need as proper set to assist me. ------- This is displayed in the .js file ------ var newMessage = messageTemplate(id, name, division, time, tag, text, type, enabled); var messageTemplate = function (id, name, division, time, tag, text, type, enabled) { ------- This is displayed in the view-source: ------ //Load all messages, teams, tags and incidents $(document).ready(function () { //Show the appropriate messages upon loading UserPreferences = JSON.parse('{"Team":true,"Masterincidenten":true,"Sos":true,"Meldingen":true,"Chat":true}'); addMessages([{"MessageID":19652,"Timestamp":"2019-12-24T07:46:51.713","Tag":"","Text":"Here is the supposed text","Type":"Chat","Votes":1,"Enabled":true,"User":{"Name":"Kaasplakje","Division":"X"},"Division":"X"},
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now