Finding a difference between refreshes?

Ok so in this project, what I made is a python script that continuously refreshes a certain page and everytime, send me the body in the page. While it does work really well, the inconvenient thing is it sends a lot of msgs (1 msg a second when I have the bot running)
I’d like to make it so the bot only says something, when it sees that the webpage’s body has changed. How would it be possible?

You can use the difflib or filcmp modules to compare previous text/file → current text/file and only do reload if there’s a diff

What do you exactly mean here? Yes, I could compare the two together but how am I supposed to only reload when there’s a diff? I have no way to know when the page would be changed

but you can send a message only when there is a change

Yeah but how? It’s what im trying to figure out.

Get text
  Store that (or just "" if it's very first run)

Get text
  Run diff on that and stored text
  Does diff return true?
    Yes, refresh.
    No, don't.

How am I supposed to get the 2nd text without refreshing in the first place?
Sorry if I sound really dumb I’m really new to coding.

Do you not control this page or the files for the page? I may have assumed you were trying to do something else. If not then yes you have to refresh the page, but you can still diff to check if you need to send a message

1 Like

Yeah I don’t have control over the page but I just realized I could refresh, compare the two and send if a difference was found. Thanks for the help.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.