Jump to content
UBot Underground

Compare Two Tables


Recommended Posts

hey guys

i have 2 tables old_db_data and new_db_data that I want to compare for change, but i keep getting the wrong result

my issue is that the below list information are the same, so the alert should be page is the same

but weather the list information is the same or not I still get the same result page is different

any 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)
            }
        }
    }
}
Link to post
Share on other sites

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

Link to post
Share on other sites

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 file

2. 12 hrs latter, scrape all 12 pages again and check for any changes

3. 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

Link to post
Share on other sites

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

 

post-5979-0-26629500-1490834270_thumb.png

 

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...