SmileyBot 13 Posted March 29, 2017 Report Share Posted March 29, 2017 hey guysi have 2 tables old_db_data and new_db_data that I want to compare for change, but i keep getting the wrong resultmy issue is that the below list information are the same, so the alert should be page is the samebut weather the list information is the same or not I still get the same result page is differentany ideas, thanks in advance clear all data add list to list(%old_db_data,$list from text("Helpdesk If any tool is not working just open ticket through help desk @gmail.com",""),"Delete","Global") add list to list(%new_db_data,$list from text("Helpdesk If any tool is not working just open ticket through help desk @gmail.com",""),"Delete","Global") create table from text(&old_db_data,%old_db_data) divider divider set(#old_db_data_row,0,"Global") loop($list total(%new_db_data)) { set(#next_item,$next list item(%new_db_data),"Global") set(#row_num,0,"Global") loop($table total rows(&old_db_data)) { if($comparison(#next_item,"=",$table cell(&old_db_data,#row_num,0))) { then { alert("page is the same") increment(#old_db_data_row) } else { alert("page is different") increment(#old_db_data_row) } } } } Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted March 29, 2017 Report Share Posted March 29, 2017 Hi, You really cant put multiple lines in a table cell like that. You will notice you only have the first line in you table.I am not sure of your grand scheme but why do need the table?Why not just compare the lists? clear all data add list to list(%old_db_data,$list from text("Helpdesk If any tool is not working just open ticket through help desk @gmail.com",""),"Delete","Global") add list to list(%new_db_data,$list from text("Helpdesk If any tool is not working just open ticket through help desk @gmail.com",""),"Delete","Global") if($comparison(%old_db_data,"= Equals",%new_db_data)) { then { alert("true") } else { alert("false") } } Regards,Nick Quote Link to post Share on other sites
SmileyBot 13 Posted March 29, 2017 Author Report Share Posted March 29, 2017 Thanks Nick,I thought the fact I had multiple lines in the cell may have been the problem. my goal is to see if a website has updated it's information and alert. The script runs:1. scrapes all 12 pages of a website and saves the data into a file2. 12 hrs latter, scrape all 12 pages again and check for any changes3. if comparison = different, then alert when trying to bring scraped page data back into the script the data gets messed up when trying to create list from file/table,so i have to use create table from list it seems simple enough, any ideas Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted March 30, 2017 Report Share Posted March 30, 2017 ya, no problem, Read the response header of the page with an HTTP request. In that you will find an "Etag" which can tell you the last time it was updated in UNIX time/md5 of timestamp. Save that to a table and compare it next time. Another option is to get the MD5 hash of the body/HTML($document text) and compare. I think kev123 as a plugin.or you can do with ironpython(ubot) but typically in an RSS feed you will get the md5 hash of the timestamp that one could compare. https://en.wikipedia.org/wiki/HTTP_ETag If you roll with HTTP I would do a "HEAD" check so you are not downloading the entire page and just get header info. A little faster and easier on the server. or you may just be able to compare last updated timestamps. Depends on the site Regards,Nick Quote Link to post Share on other sites
SmileyBot 13 Posted March 30, 2017 Author Report Share Posted March 30, 2017 I used the MD5 plugin and got the hash of the body/HTML($document text) and compared. thanks 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.